コード例 #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"))
コード例 #2
0
ファイル: test_basic.py プロジェクト: zxli27/myprojects
 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)
コード例 #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"))
コード例 #4
0
ファイル: test_basic.py プロジェクト: zxli27/myprojects
 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)
コード例 #5
0
ファイル: test_basic.py プロジェクト: zxli27/myprojects
 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)
コード例 #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"))
コード例 #7
0
ファイル: test_ping.py プロジェクト: zxli27/myprojects
 def test_ping(self):
     tester = app.test_client(self)
     response = tester.get("/api/ping")
     code = response.status_code
     self.assertEqual(code, 200)
コード例 #8
0
ファイル: test_basic.py プロジェクト: zxli27/myprojects
 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)
コード例 #9
0
ファイル: test_basic.py プロジェクト: zxli27/myprojects
 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)