-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
58 lines (41 loc) · 1.4 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
50
51
52
53
54
55
56
57
58
import os
import unittest
from app import create_app, db
from app.default_conf import Config
class TestConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite://'
DEBUG = False
FLASK_ENV = 'testing'
class BaseCase(unittest.TestCase):
def setUp(self):
self.app = create_app(TestConfig)
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
self.testapp = self.app.test_client()
def tearDown(self):
db.session.remove()
db.drop_all()
self.app_context.pop()
def test_set_up(self):
self.assertEqual(self.app.debug, False)
class RiotConnectorCase(BaseCase):
def test_api_key_exists(self):
self.assertTrue(os.environ.get('API_KEy') is not None)
class RouteCase(BaseCase):
def test_main_page(self):
response = self.testapp.get('/')
self.assertEqual(response.status_code, 200)
def test_main_page_post(self):
response = self.testapp.post('/')
self.assertEqual(response.status_code, 200)
def test_index(self):
response = self.testapp.get('/index')
self.assertEqual(response.status_code, 200)
def test_index_post(self):
response = self.testapp.post('/index')
self.assertEqual(response.status_code, 200)
if __name__ == '__main__':
if __name__ == '__main__':
unittest.main(verbosity=2)