def test_add_comment(self, mock_update): rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1) issue.add_comment('hola') mock_update.assert_called_with( comment='hola' )
def test_file_attach(self, mock_new_resource, mock_open): fd = open("tests/resources/tasks_list_success.json") mock_open.return_value = fd rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1, project=1) issue.attach("tests/resources/tasks_list_success.json") mock_new_resource.assert_called_with(files={"attached_file": fd}, payload={"project": 1, "object_id": 1})
def test_downvote(self, mock_requestmaker_post): rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1) self.assertEqual(issue.downvote().id, 1) mock_requestmaker_post.assert_called_with('/{endpoint}/{id}/downvote', endpoint='issues', id=1)
def test_downvote(self, mock_requestmaker_post): rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1) self.assertEqual(issue.downvote().id, 1) mock_requestmaker_post.assert_called_with( '/{endpoint}/{id}/downvote', endpoint='issues', id=1 )
def test_open_file_attach(self, mock_new_resource): fd = open('tests/resources/tasks_list_success.json') rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1, project=1) issue.attach(fd) mock_new_resource.assert_called_with( files={'attached_file': fd}, payload={'project': 1, 'object_id': 1} )
def test_get_issue_custom_attributes(self, mock_requestmaker_get): mock_requestmaker_get.return_value = MockResponse(200, create_mock_json('tests/resources/issue_customattr_success.json')) rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1, project=1) my_attributes = issue.get_attributes() self.assertTrue('attributes_values' in my_attributes) mock_requestmaker_get.assert_called_with( '/{endpoint}/custom-attributes-values/{id}', endpoint=Issue.endpoint, id=issue.id, cache=False )
def test_get_issue_custom_attributes(self, mock_requestmaker_get): mock_requestmaker_get.return_value = MockResponse(200, create_mock_json('tests/resources/issue_customattr_success.json')) rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1, project=1) my_attributes = issue.get_attributes() self.assertTrue('attributes_values' in my_attributes) mock_requestmaker_get.assert_called_with( '/{endpoint}/custom-attributes-values/{id}', endpoint=Issue.endpoint, id=issue.id, )
def test_list_attachments(self, mock_requestmaker_get): rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') Issue(rm, id=1).list_attachments() mock_requestmaker_get.assert_called_with( 'issues/attachments', query={"object_id": 1}, )
def test_list_attachments(self, mock_requestmaker_get): mock_requestmaker_get.return_value = MockResponse( 200, create_mock_json("tests/resources/issues_list_success.json") ) rm = RequestMaker("/api/v1", "fakehost", "faketoken") Issue(rm, id=1).list_attachments() mock_requestmaker_get.assert_called_with("issues/attachments", query={"object_id": 1}, paginate=True)
def test_edit_issue_custom_attribute(self, mock_requestmaker_patch, mock_requestmaker_get): mock_requestmaker_get.return_value = MockResponse(200, create_mock_json('tests/resources/issue_customattr_success.json')) mock_requestmaker_patch.return_value = MockResponse(200, create_mock_json('tests/resources/issue_customattr_success.json')) rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1, project=1) new_attribute = issue.set_attribute(1, 13) self.assertTrue('attributes_values' in new_attribute) mock_requestmaker_patch.assert_called_with( '/{endpoint}/custom-attributes-values/{id}', endpoint=Issue.endpoint, id=issue.id, payload={ 'attributes_values': {u'1': 13}, 'version': 1 } )
def test_edit_issue_custom_attribute(self, mock_requestmaker_patch, mock_requestmaker_get): mock_requestmaker_get.return_value = MockResponse( 200, create_mock_json("tests/resources/issue_customattr_success.json") ) mock_requestmaker_patch.return_value = MockResponse( 200, create_mock_json("tests/resources/issue_customattr_success.json") ) rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1, project=1) new_attribute = issue.set_attribute(1, 13) self.assertTrue("attributes_values" in new_attribute) mock_requestmaker_patch.assert_called_with( "/{endpoint}/custom-attributes-values/{id}", endpoint=Issue.endpoint, id=issue.id, payload={"attributes_values": {"1": 13}, "version": 1}, )
def test_not_existing_file_attach(self): rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1, project=1) self.assertRaises(TaigaException, issue.attach, "not-existing-file")
def test_downvote(self, mock_requestmaker_post): rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1) self.assertEqual(issue.downvote().id, 1) mock_requestmaker_post.assert_called_with("/{endpoint}/{id}/downvote", endpoint="issues", id=1)
def test_not_existing_file_attach(self): rm = RequestMaker('/api/v1', 'fakehost', 'faketoken') issue = Issue(rm, id=1, project=1) self.assertRaises(TaigaException, issue.attach, 'not-existing-file')
def test_not_valid_type_file_attach(self): rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1, project=1) self.assertRaises(TaigaException, issue.attach, 4)
def test_add_comment(self, mock_update): rm = RequestMaker("/api/v1", "fakehost", "faketoken") issue = Issue(rm, id=1) issue.add_comment("hola") mock_update.assert_called_with(comment="hola")