Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an automated test suite #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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