Ejemplo n.º 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"))
Ejemplo n.º 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)
Ejemplo n.º 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"))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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"))
Ejemplo n.º 7
0
 def test_ping(self):
     tester = app.test_client(self)
     response = tester.get("/api/ping")
     code = response.status_code
     self.assertEqual(code, 200)
Ejemplo n.º 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)
Ejemplo n.º 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)