diff --git a/tests.py b/tests.py index a90b292..1726068 100644 --- a/tests.py +++ b/tests.py @@ -1,3 +1,4 @@ +import time import unittest from unittest import TestCase @@ -48,6 +49,17 @@ class SnapPassTestCase(TestCase): "/", data={'password': 'foo', 'ttl': 'hour'}, method='POST'): self.assertEqual((3600, 'foo'), snappass.clean_input()) + def test_password_before_expiration(self): + password = 'fidelio' + key = snappass.set_password(password, 1) + self.assertEqual(password, snappass.get_password(key)) + + def test_password_after_expiration(self): + password = 'open sesame' + key = snappass.set_password(password, 1) + time.sleep(1.5) + self.assertEqual(None, snappass.get_password(key)) + class SnapPassRoutesTestCase(TestCase): # noinspection PyPep8Naming