-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_tests.py
73 lines (62 loc) · 1.95 KB
/
server_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import json
import server
import unittest
class ServerTestCase(unittest.TestCase):
def setUp(self):
self.app = server.app.test_client()
def tearDown(self):
pass
def test_objectivity(self):
data = {
'text': 'This is some random text.',
}
expected_data = {
"objectivity": 0.5
}
response = self.app.post('/', data=data, follow_redirects=True)
response_json = json.loads(response.data)
assert(response_json == expected_data)
def test_integer_objectivity(self):
data = {
'text': 100,
}
expected_data = {
"objectivity": 1.0
}
response = self.app.post('/', data=data, follow_redirects=True)
response_json = json.loads(response.data)
assert(response_json == expected_data)
def test_ascii_objectivity(self):
data = {
'text': u'\u2019',
}
expected_data = {
"objectivity": 1.0
}
response = self.app.post('/', data=data, follow_redirects=True)
response_json = json.loads(response.data)
assert(response_json == expected_data)
def test_empty_text(self):
data = {
'wrong': 'Empty text field',
}
expected_data = {
"objectivity": 1.0
}
response = self.app.post('/', data=data, follow_redirects=True)
response_json = json.loads(response.data)
assert(response_json == expected_data)
def test_sentence_starting_with_whitespace(self):
data = {
'wrong': ' try to get loud please',
}
expected_data = {
"objectivity": 1.0
}
response = self.app.post('/', data=data, follow_redirects=True)
response_json = json.loads(response.data)
assert(response_json == expected_data)
if __name__ == '__main__':
unittest.main()