-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
47 lines (37 loc) · 1.35 KB
/
Copy pathtests.py
File metadata and controls
47 lines (37 loc) · 1.35 KB
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import unittest
import json
from main import app
class TestMethods(unittest.TestCase):
"""docstring for TestMethods"""
def setUp(self):
test = app.test_client(self)
response = test.get('/', content_type='html/text')
self.assertEqual(response.status_code, 200)
def post(self):
test = app.test_client(self)
response = test.post('/api', content_type='html/text')
self.assertEqual(response.status_code, 200)
def test1(self):
test = app.test_client(self)
data = \
json.dumps(['Congratulations ur awarded either \xc3\xa5\xc2\xa3500 of CD '
])
response = test.post('/test', data=data)
result = json.loads(response.data)
self.assertEqual(result['results'], 'spam')
def test2(self):
test = app.test_client(self)
data = json.dumps(['Hi how are you '])
response = test.post('/test', data=data)
result = json.loads(response.data)
self.assertEqual(result['results'], 'ham')
def test3(self):
test = app.test_client(self)
data = json.dumps([' '])
response = test.post('/test', data=data)
result = json.loads(response.data)
self.assertEqual(result['results'], 'ham')
if __name__ == '__main__':
unittest.main()