Skip to content

Commit

Permalink
Merge pull request #83 from samueldg/enhancement/modernize-tests
Browse files Browse the repository at this point in the history
Enhancement/modernize tests
  • Loading branch information
nichochar authored May 8, 2018
2 parents 548c998 + d407c26 commit 5ddecd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def test_get_password(self):
key = snappass.set_password(password, 30)
self.assertEqual(password, snappass.get_password(key))
# Assert that we can't look this up a second time.
self.assertEqual(None, snappass.get_password(key))
self.assertIsNone(snappass.get_password(key))

def test_password_is_not_stored_in_plaintext(self):
password = "trustno1"
token = snappass.set_password(password, 30)
redis_key = token.split(snappass.TOKEN_SEPARATOR)[0]
stored_password_text = snappass.redis_client.get(redis_key).decode('utf-8')
self.assertFalse(password in stored_password_text)
self.assertNotIn(password, stored_password_text)

def test_returned_token_format(self):
password = "trustsome1"
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_password_after_expiration(self):
# Expire functionality must be explicitly invoked using do_expire(time).
# mockredis does not support automatic expiration at this time
snappass.redis_client.do_expire()
self.assertEqual(None, snappass.get_password(key))
self.assertIsNone(snappass.get_password(key))


class SnapPassRoutesTestCase(TestCase):
Expand All @@ -110,7 +110,7 @@ def test_show_password(self):
password = "I like novelty kitten statues!"
key = snappass.set_password(password, 30)
rv = self.app.get('/{0}'.format(key))
self.assertTrue(password in rv.get_data(as_text=True))
self.assertIn(password, rv.get_data(as_text=True))

def test_bots_denial(self):
"""
Expand All @@ -131,7 +131,7 @@ def test_bots_denial(self):

for ua in a_few_sneaky_bots:
rv = self.app.get('/{0}'.format(key), headers={ 'User-Agent': ua })
self.assertEqual(rv.status_code, 404)
self.assertEqual(404, rv.status_code)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ setenv =
commands =
pip install -r requirements.txt
pip install -r dev-requirements.txt
py.test --junitxml=junit-{envname}.xml --cov-report xml tests.py
pytest --junitxml=junit-{envname}.xml --cov-report xml tests.py

[testenv:flake8]
commands =
Expand Down

0 comments on commit 5ddecd4

Please sign in to comment.