-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split the tests into separate files; added real changelog
- Loading branch information
1 parent
f1c03e9
commit 41aa19f
Showing
8 changed files
with
133 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#Changelog | ||
|
||
##1.1 | ||
* switched to py.test for tests | ||
* form tests | ||
* url tests | ||
* testing database submitting on model tests | ||
* added documentation on how to deploy your application | ||
|
||
##1.0 | ||
* MVC with blueprints, SQLAlchemy models, and templates | ||
* A makefile | ||
* nose tests | ||
* Flask-Assets css and js management | ||
* Flask-Cache for caching jinja templates | ||
* A Flask-Script management script | ||
* Flask-WTF form management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! ../env/bin/python | ||
# -*- coding: utf-8 -*- | ||
from appname import create_app | ||
|
||
|
||
class TestConfig: | ||
def test_dev_config(self): | ||
app = create_app('appname.settings.DevConfig', env='dev') | ||
|
||
assert app.config['DEBUG'] is True | ||
assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' | ||
assert app.config['SQLALCHEMY_ECHO'] is True | ||
assert app.config['CACHE_TYPE'] == 'null' | ||
|
||
def test_prod_config(self): | ||
app = create_app('appname.settings.ProdConfig', env='prod') | ||
|
||
assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db' | ||
assert app.config['CACHE_TYPE'] == 'simple' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#! ../env/bin/python | ||
# -*- coding: utf-8 -*- | ||
from appname import create_app | ||
from appname.models import db | ||
|
||
|
||
class TestForm: | ||
def setup(self): | ||
app = create_app('appname.settings.DevConfig', env='dev') | ||
self.app = app.test_client() | ||
db.app = app | ||
db.create_all() | ||
|
||
def teardown(self): | ||
db.session.remove() | ||
db.drop_all() | ||
|
||
def test_user_form_empty(self): | ||
rv = self.app.post('/wtform', data=dict( | ||
user_name="", | ||
message="" | ||
), follow_redirects=True) | ||
|
||
assert rv.status_code == 200 | ||
assert 'There was a problem submitting the form!' in rv.data | ||
|
||
def test_user_form_name(self): | ||
rv = self.app.post('/wtform', data=dict( | ||
user_name="admin", | ||
message="" | ||
), follow_redirects=True) | ||
|
||
assert rv.status_code == 200 | ||
assert 'The form was successfully submitted' in rv.data | ||
|
||
def test_user_form_both(self): | ||
rv = self.app.post('/wtform', data=dict( | ||
user_name="admin", | ||
message="test message" | ||
), follow_redirects=True) | ||
|
||
assert rv.status_code == 200 | ||
assert 'The form was successfully submitted' in rv.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#! ../env/bin/python | ||
# -*- coding: utf-8 -*- | ||
from appname import create_app | ||
from appname.models import db, User | ||
|
||
|
||
class TestModels: | ||
def setup(self): | ||
app = create_app('appname.settings.DevConfig', env='dev') | ||
self.app = app.test_client() | ||
db.app = app | ||
db.create_all() | ||
|
||
def teardown(self): | ||
db.session.remove() | ||
db.drop_all() | ||
|
||
def test_user(self): | ||
admin = User('admin', 'supersafepassword') | ||
|
||
assert admin.username == 'admin' | ||
assert admin.password == 'supersafepassword' | ||
|
||
db.session.add(admin) | ||
db.session.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#! ../env/bin/python | ||
# -*- coding: utf-8 -*- | ||
from appname import create_app | ||
from appname.models import db | ||
|
||
|
||
class TestURLs: | ||
def setup(self): | ||
app = create_app('appname.settings.DevConfig', env='dev') | ||
self.app = app.test_client() | ||
db.app = app | ||
db.create_all() | ||
|
||
def teardown(self): | ||
db.session.remove() | ||
db.drop_all() | ||
|
||
def test_home(self): | ||
rv = self.app.get('/') | ||
assert rv.status_code == 200 | ||
|
||
def test_form(self): | ||
rv = self.app.get('/wtform') | ||
assert rv.status_code == 200 |