Adding tests for 400 and 405 pages

This commit is contained in:
Denis-Cosmin Nutiu 2017-04-20 16:24:59 +03:00
parent 6cda07e58a
commit e4280c7304

View file

@ -60,7 +60,7 @@ class ScoreboardTestCase(unittest.TestCase):
gpu="CpuTesting2",
cpu="GPUTesting2",
log="This is a logfile",
score=200
score="200"
)
response = self.client.post('/result', data=json.dumps(data), content_type='application/json')
@ -82,6 +82,15 @@ class ScoreboardTestCase(unittest.TestCase):
response = self.client.get('/upload')
self.assertEqual(response.status_code, 200)
def test_method_not_allowed(self):
response = self.client.post('/upload')
self.assertEqual(response.status_code, 405)
self.assertTrue("405" in response.get_data(as_text=True))
def test_bad_request(self):
response = self.client.post('/result', data={'mambo':'jambo'})
self.assertEqual(response.status_code, 400)
def test_pagination(self):
data1 = Result(cpu="TestCPU", gpu="TestGPU", log="TestLOG", score=11)
data2 = Result(cpu="TestCPU", gpu="TestGPU", log="TestLOG", score=22)