-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app.py
34 lines (27 loc) · 1.11 KB
/
test_app.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
import unittest
from app import app, get_list, get_primes
class TestPrimeNumbersListing(unittest.TestCase):
def test_correct_list(self):
tester = app.test_client(self);
response = tester.get('/10')
self.assertEqual(get_list(10), [2,3,5,7])
self.assertEqual(response.status_code, 200)
def test_incorrect_list(self):
tester = app.test_client(self);
response = tester.get('/1')
self.assertEqual(get_list(10), [2,3,5,7])
self.assertEqual(response.status_code, 400)
def test_correct_primes(self):
tester = app.test_client(self);
response = tester.get('/10')
self.assertEqual(get_primes(10), [3, 5, 7])
self.assertEqual(response.status_code, 200)
def test_incorrect_primes(self):
tester = app.test_client(self);
response = tester.get('/1')
self.assertEqual(get_primes(10), [3, 5, 7])
self.assertEqual(response.status_code, 400)
def test_incorrect_route(self):
tester = app.test_client(self);
response = tester.get('/')
self.assertEqual(response.status_code, 400)