- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
Latest commit
32 lines (26 loc) · 1.49 KB
/
Copy pathtest.py
File metadata and controls
32 lines (26 loc) · 1.49 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
importunittest
fromrunimportrun
classTestParaphraseEndpoint(unittest.TestCase):
defsetUp(self):
self.run=run.test_client()
deftest_paraphrase_endpoint_success(self):
expected= {
"paraphrases": [
{"tree": "(S (NP (DT the) (NN cat)) (VP (VBD sat) (PP (IN on) (NP (DT the) (NN mat)))))"},
{"tree": "(S (NP (DT the) (NN mat)) (VP (VBD was) (VP (VBN sat) (PP (IN on) (NP (DT by) (DT the) (NN cat))))))"},
{"tree": "(S (NP (DT the) (NN cat)) (VP (VBD sat) (PP (IN on) (NP (DT the) (NN rug)))))"},
{"tree": "(S (NP (DT the) (NN rug)) (VP (VBD was) (VP (VBN sat) (PP (IN on) (NP (DT by) (DT the) (NN cat))))))"},
{"tree": "(S (NP (DT the) (NN mat)) (VP (VBD was) (VP (VBN sat) (PP (IN on) (NP (DT by) (DT the) (NN cat))))))"},
{"tree": "(S (NP (DT the) (NN rug)) (VP (VBD was) (VP (VBN sat) (PP (IN on) (NP (DT by) (DT the) (NN cat))))))"}
]
}
tree_str="(S (NP (DT the) (NN cat)) (VP (VBD sat) (PP (IN on) (NP (DT the) (NN mat)))))"
response=self.run.get(f"/paraphrase?tree={tree_str}&limit=6")
assertexpected==response.json
deftest_paraphrase_endpoint_error(self):
expected= {"error": "Missing \"tree\" parameter."}
response=self.run.get("/paraphrase")
self.assertEqual(response.status_code, 400)
self.assertDictEqual(response.json, expected)
if__name__=='__main__':
unittest.main()