-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
43 lines (32 loc) · 1.3 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
import random
import unittest
from unittest import TestCase
from app import app
import routes.consultations
from static import Static
links = Static.consultation_links()
class FlaskTests(TestCase):
def setUp(self):
self.client = app.test_client(self)
def test_root(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 302)
def test_changes(self):
response = self.client.get('/changes')
self.assertEqual(response.status_code, 200)
def test_whole_consultations(self):
response = self.client.get('/consultations')
self.assertEqual(response.status_code, 200)
def test_random_consultations(self):
random_consultations = random.randint(0, 6)
print(f'Randomly selected consultations: {random_consultations}')
response = self.client.get('/consultations', json={'department': random_consultations})
self.assertEqual(response.status_code, 200)
def test_undefined_consultations(self):
response = self.client.get('/consultations', json={'department': 7})
self.assertEqual(response.status_code, 400)
def test_undefined_route(self):
response = self.client.get('/undefined')
self.assertEqual(response.status_code, 404)
if __name__ == '__main__':
unittest.main()