-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
43 lines (32 loc) · 1.16 KB
/
test.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import unittest
import platform
class TestFib(unittest.TestCase):
def test_service(self):
"""
This is to verify functionality.
:return: "This is the root for RESTful web service"
........"""
response = requests.get('http://127.0.0.1:5000/'.format(platform.node()))
self.assertEqual(200, response.status_code,
response.status_code)
def test_negative(self):
"""
This will respond with an appropriate error.
:return: "Error! Number provided is not a positive number"
........"""
response = \
requests.get('http://127.0.0.1:5000/fibonacci/-1'.format(platform.node()))
self.assertEqual(200, response.status_code,
response.status_code)
def test_example(self):
"""
This will check that the example matches (n=5 [0,1,1,2,3])
........"""
response = \
requests.get('http://127.0.0.1:5000/fibonacci/5'.format(platform.node()))
self.assertEqual(b'[0, 1, 1, 2, 3]',response.content)
if __name__ == '__main__':
unittest.main()