Beispiel #1
0
 def test_direction_effect(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=culture&direction=asc")
     posts = json.loads(response.data)
     self.assertTrue(is_correctly_sorted(posts, "id", "asc"))
     response = tester.get("/api/posts?tags=culture&direction=desc")
     posts = json.loads(response.data)
     self.assertTrue(is_correctly_sorted(posts, "id", "desc"))
Beispiel #2
0
 def test_direction_valid(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=foo&sdirection=asc")
     code = response.status_code
     self.assertEqual(code, 200)
     response = tester.get("/api/posts?tags=foo&direction=rise")
     code = response.status_code
     self.assertEqual(code, 400)
Beispiel #3
0
 def test_sortBy_effect(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=culture&sortBy=id")
     posts = json.loads(response.data)
     self.assertTrue(is_correctly_sorted(posts, "id", "asc"))
     response = tester.get("/api/posts?tags=culture&sortBy=likes")
     posts = json.loads(response.data)
     self.assertTrue(is_correctly_sorted(posts, "likes", "asc"))
Beispiel #4
0
 def test_sortBy_valid(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=foo&sortBy=id")
     code = response.status_code
     self.assertEqual(code, 200)
     response = tester.get("/api/posts?tags=foo&sortBy=author")
     code = response.status_code
     self.assertEqual(code, 400)
Beispiel #5
0
 def test_tags_necessity(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts")
     code = response.status_code
     self.assertEqual(code, 400)
     response = tester.get("/api/posts?tags=foo")
     code = response.status_code
     self.assertEqual(code, 200)
Beispiel #6
0
 def test_tags_no_duplication(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=culture&direction=asc")
     posts = json.loads(response.data)
     self.assertTrue(is_not_duplicated(posts, "id"))
Beispiel #7
0
 def test_ping(self):
     tester = app.test_client(self)
     response = tester.get("/api/ping")
     code = response.status_code
     self.assertEqual(code, 200)
Beispiel #8
0
 def test_more_paras(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=foo,void,bar&sortBy=likes&direction=asc&author=Mike")
     code = response.status_code
     self.assertEqual(code, 200)
Beispiel #9
0
 def test_tags_format(self):
     tester = app.test_client(self)
     response = tester.get("/api/posts?tags=foo,void,bar")
     code = response.status_code
     self.assertEqual(code, 200)