-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
50 lines (40 loc) · 1.16 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
47
48
49
from datetime import datetime
import unittest
from app import create_app, db
from app.models import DbGame
from config import Config
def push_games():
games = [
# TODO
]
for idx, game in enumerate(games):
new_game = DbGame(
# TODO
)
db.session.add(new_game)
db.session.commit()
class TestConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = "sqlite://"
WTF_CSRF_ENABLED = False
SECRET_KEY = "very-secret"
class MainViewCase(unittest.TestCase):
def setUp(self):
self.app = create_app(TestConfig)
self.app_context = self.app.app_context()
self.app_context.push()
self.test_client = self.app.test_client()
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
self.app_context.pop()
def test_index_view(self):
rsp = self.test_client.get("/")
self.assertEqual(rsp.status, "200 OK")
self.assertTrue(
'<a class="hidden ajaxurl" id="ajaxurl" href="/ajax">/ajax</a>'
in rsp.get_data(as_text=True)
)
if __name__ == "__main__":
unittest.main(verbosity=1)