From f03b81b31c2ff407839d3119deaf9024252bdb6f Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Fri, 20 May 2016 18:00:52 +0800 Subject: add unittests for testcase and refactor testcase related implementation modification: add unittests for testcase refactor testcase table name in db to testcases refactor response body fix some bugs JIRA:FUNCTEST-254 Change-Id: Ia7c7101fa742af82bfc8c4a3d398a7dad601bca1 Signed-off-by: SerenaFeng --- result_collection_api/tests/unit/test_project.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'result_collection_api/tests/unit/test_project.py') diff --git a/result_collection_api/tests/unit/test_project.py b/result_collection_api/tests/unit/test_project.py index e793111..6ce21db 100644 --- a/result_collection_api/tests/unit/test_project.py +++ b/result_collection_api/tests/unit/test_project.py @@ -66,23 +66,23 @@ class TestProjectGet(TestProjectBase): class TestProjectUpdate(TestProjectBase): def test_withoutBody(self): - code, _ = self.update('noBody') + code, _ = self.update(None, 'noBody') self.assertEqual(code, HTTP_BAD_REQUEST) def test_notFound(self): - code, _ = self.update('notFound', self.req_e) + code, _ = self.update(self.req_e, 'notFound') self.assertEqual(code, HTTP_NOT_FOUND) def test_newNameExist(self): self.create_d() self.create_e() - code, body = self.update(self.req_d.name, self.req_e) + code, body = self.update(self.req_e, self.req_d.name) self.assertEqual(code, HTTP_FORBIDDEN) self.assertIn("already exists", body) def test_noUpdate(self): self.create_d() - code, body = self.update(self.req_d.name, self.req_d) + code, body = self.update(self.req_d, self.req_d.name) self.assertEqual(code, HTTP_FORBIDDEN) self.assertIn("Nothing to update", body) @@ -92,7 +92,7 @@ class TestProjectUpdate(TestProjectBase): _id = body._id req = ProjectCreateRequest('newName', 'new description') - code, body = self.update(self.req_d.name, req) + code, body = self.update(req, self.req_d.name) self.assertEqual(code, HTTP_OK) self.assertEqual(_id, body._id) self.assert_body(body, req) @@ -104,13 +104,17 @@ class TestProjectUpdate(TestProjectBase): class TestProjectDelete(TestProjectBase): def test_notFound(self): - code = self.delete('notFound') + code, body = self.delete('notFound') self.assertEqual(code, HTTP_NOT_FOUND) def test_success(self): self.create_d() - code = self.delete(self.req_d.name) + code, body = self.delete(self.req_d.name) self.assertEqual(code, HTTP_OK) + self.assertEqual(body, '') + + code, body = self.get(self.req_d.name) + self.assertEqual(code, HTTP_NOT_FOUND) if __name__ == '__main__': unittest.main() -- cgit 1.2.3-korg