Skip to content

Commit

Permalink
Create an automated test suite
Browse files Browse the repository at this point in the history
* fixes, jeffknupp#2
* unittest2 was replaced by py.test
* previous test was repaired
* notes on running tests was added to README.md
  • Loading branch information
amezhenin committed Mar 29, 2014
1 parent 4b620fb commit 9edef94
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ virtualenv --no-site-packages venv
source venv/bin/activate
pip install -r requirements.txt
```

### Testing

Run all tests:

$ nosetest

Run all tests with coverage:

$ nosetests --with-coverage

Run some particular test:

$ nosetests review.test
$ nosetests review.test:test_simple
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ wsgiref==0.1.2
nose==1.3.0
coverage==3.7.1
coveralls
unittest2==0.5.1
pytest==2.5.2
2 changes: 1 addition & 1 deletion review/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import humanize
def show_stars(score):
return ''.join(['<i class="fa fa-star"></i>' for _ in range(score)])
return '<i class="fa fa-star"></i>' * score

def naturaltime(datetime):
return humanize.naturaltime(datetime)
29 changes: 17 additions & 12 deletions review/test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
"""Tests for review app."""

from views import app
from unittest2 import TestCase
from .views import app
import pytest

class ReviewTest(TestCase):

def setup(self):
self.app = app.test_client()

def test_simpe(self):
self.assertEquals(1 + 1, 2)
def test_main_list():
"""Can we successfully retrieve a list of reviews?"""
client = app.test_client()
response = client.get('/')
assert response.status_code == 200
assert 'Reviews' in response.data


def test_simple():
assert 1 + 1 == 2


if __name__ == '__main__':
pytest.main()


def _test_main_list(self):
"""Can we successfully retrieve a list of reviews?"""
response = self.app.get('/')
assert 'All Reviews' in response.data
1 change: 0 additions & 1 deletion review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def login():
if request.method == 'POST':
if form.validate_on_submit():
user = User.query.get(form.email.data)
print user
if user and bcrypt.check_password_hash(user.password, form.password.data):
if login_user(user):
user.authenticated = True
Expand Down

0 comments on commit 9edef94

Please sign in to comment.