-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
46 lines (34 loc) · 1.14 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Testing module for global scope tests."""
import unittest
from app import create_app, db
from app.models import User
from config import TestConfig
def reverse_string(test_str):
"""Return a reversed string.
Args:
test_str: The string to be reversed.
"""
return "".join(reversed(test_str))
class BuildTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app(TestConfig)
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
self.app_context.pop()
def test_mini(self):
"""Mock test for CI purposes asserting equality of a reversed string."""
test_str = "testing"
reversed_true = "gnitset"
reversed_str = reverse_string(test_str)
self.assertEqual(reversed_true, reversed_str)
def test_password_hashing(self):
u = User(username="test")
u.set_password("cat")
self.assertFalse(u.check_password("dog"))
self.assertTrue(u.check_password("cat"))
if __name__ == "__main__":
unittest.main(verbosity=2)