Exemplo n.º 1
0
 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'
     )
Exemplo n.º 2
0
 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'
     )
Exemplo n.º 3
0
 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})
Exemplo n.º 4
0
 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})
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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
     )
Exemplo n.º 7
0
 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}
     )
Exemplo n.º 8
0
 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,
     )
Exemplo n.º 10
0
 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},
     )
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 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
         }
     )
Exemplo n.º 13
0
 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},
     )
Exemplo n.º 14
0
 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
         }
     )
Exemplo n.º 15
0
 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")
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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')
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 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")
Exemplo n.º 20
0
 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)