class TestProjectUpdate(TestProjectBase): def setUp(self): super(TestProjectUpdate, self).setUp() _, d_body = self.create_d() _, get_res = self.get(self.req_d.name) self.index_d = get_res._id self.create_e() @executor.update(httplib.BAD_REQUEST, message.no_body()) def test_withoutBody(self): return None, 'noBody' @executor.update(httplib.NOT_FOUND, message.not_found_base) def test_notFound(self): return self.req_e, 'notFound' @executor.update(httplib.FORBIDDEN, message.exist_base) def test_newNameExist(self): return self.req_e, self.req_d.name @executor.update(httplib.FORBIDDEN, message.no_update()) def test_noUpdate(self): return self.req_d, self.req_d.name @executor.update(httplib.OK, '_assert_update') def test_success(self): req = project_models.ProjectUpdateRequest('newName', 'new description') return req, self.req_d.name def _assert_update(self, req, body): self.assertEqual(self.index_d, body._id) self.assert_body(body, req) _, new_body = self.get(req.name) self.assertEqual(self.index_d, new_body._id) self.assert_body(new_body, req)
def _update_requests(self, data): request = dict() for k, v in self.json_args.iteritems(): request = self._update_request(request, k, v, data.__getattribute__(k)) if not request: raises.Forbidden(message.no_update()) edit_request = data.format() edit_request.update(request) return edit_request
class TestProjectUpdate(TestProjectBase): @executor.mock_valid_lfid() def setUp(self): super(TestProjectUpdate, self).setUp() _, d_body = self.create_d() _, get_res = self.get(self.req_d.name) self.index_d = get_res._id self.create_e() @executor.update(httplib.BAD_REQUEST, message.not_login()) def test_notlogin(self): req = project_models.ProjectUpdateRequest('apex', 'apex test') return req, self.req_d.name @executor.update(httplib.BAD_REQUEST, message.no_body()) def test_withoutBody(self): return None, 'noBody' @executor.mock_valid_lfid() @executor.update(httplib.NOT_FOUND, message.not_found_base) def test_notFound(self): return self.req_e, 'notFound' @executor.mock_valid_lfid() @executor.update(httplib.FORBIDDEN, message.exist_base) def test_newNameExist(self): return self.req_e, self.req_d.name @executor.mock_valid_lfid() @executor.update(httplib.FORBIDDEN, message.no_update()) def test_noUpdate(self): return self.req_d, self.req_d.name @executor.mock_valid_lfid() @executor.update(httplib.UNAUTHORIZED, message.tied_with_resource()) def test_updateNotAllowed(self): self.create_help('/api/v1/projects/%s/cases', self.testcase_d, self.req_d.name) req = project_models.ProjectUpdateRequest('apex', 'apex test') return req, self.req_d.name @executor.mock_valid_lfid() @executor.update(httplib.OK, '_assert_update') def test_success(self): req = project_models.ProjectUpdateRequest('apex', 'apex test') return req, self.req_d.name def _assert_update(self, req, body): self.assertEqual(self.index_d, body._id) self.assert_body(body, req) _, new_body = self.get(req.name) self.assertEqual(self.index_d, new_body._id) self.assert_body(new_body, req)
class TestCaseUpdate(TestCaseBase): def setUp(self): super(TestCaseUpdate, self).setUp() self.create_d() @executor.update(httplib.BAD_REQUEST, message.no_body()) def test_noBody(self): return None, 'noBody' @executor.update(httplib.NOT_FOUND, message.not_found_base) def test_notFound(self): update = tcm.TestcaseUpdateRequest(description='update description') return update, 'notFound' @executor.update(httplib.FORBIDDEN, message.exist_base) def test_newNameExist(self): self.create_e() return self.update_req, self.req_d.name @executor.update(httplib.FORBIDDEN, message.no_permission()) def test_unauthorized(self): update_req_e = tcm.TestcaseUpdateRequest(project_name="newProject", **self.req_e.format()) return update_req_e, self.req_d.name @executor.update(httplib.FORBIDDEN, message.no_update()) def test_noUpdate(self): update = tcm.TestcaseUpdateRequest(project_name=self.project, **self.req_d.format()) return update, self.req_d.name @executor.update(httplib.OK, '_update_success') def test_success(self): return self.update_req, self.req_d.name @executor.update(httplib.OK, '_update_success') def test_with_dollar(self): self.update_req.description = {'2. change': 'dollar change'} return self.update_req, self.req_d.name def _update_success(self, request, body): self.assert_update_body(body, request) _, new_body = self.get(request.name) self.assert_update_body(new_body, request)
class TestCaseUpdate(TestCaseBase): def setUp(self): super(TestCaseUpdate, self).setUp() self.create_d() @executor.update(httplib.BAD_REQUEST, message.no_body()) def test_noBody(self): return None, 'noBody' @executor.update(httplib.NOT_FOUND, message.not_found_base) def test_notFound(self): return self.update_e, 'notFound' @executor.update(httplib.FORBIDDEN, message.exist_base) def test_newNameExist(self): self.create_e() return self.update_e, self.req_d.name @executor.update(httplib.FORBIDDEN, message.no_update()) def test_noUpdate(self): return self.update_d, self.req_d.name @executor.update(httplib.OK, '_update_success') def test_success(self): return self.update_e, self.req_d.name @executor.update(httplib.OK, '_update_success') def test_with_dollar(self): update = copy.deepcopy(self.update_d) update.description = {'2. change': 'dollar change'} return update, self.req_d.name def _update_success(self, request, body): self.assert_update_body(self.req_d, body, request) _, new_body = self.get(request.name) self.assert_update_body(self.req_d, new_body, request)
def test_noUpdate(self): self.create_d() code, body = self.update(self.update_d, self.req_d.name) self.assertEqual(code, httplib.FORBIDDEN) self.assertIn(message.no_update(), body)