Beispiel #1
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     task = Task(rm, id=1)
     task.add_comment('hola')
     mock_update.assert_called_with(
         comment='hola'
     )
Beispiel #2
0
 def test_open_file_attach(self, mock_new_resource):
     fd = open('tests/resources/tasks_list_success.json')
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     task = Task(rm, id=1, project=1)
     task.attach(fd)
     mock_new_resource.assert_called_with(
         files={'attached_file': fd},
         payload={'project': 1, 'object_id': 1}
     )
Beispiel #3
0
 def test_open_file_attach(self, mock_new_resource):
     fd = open("tests/resources/tasks_list_success.json")
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     task = Task(rm, id=1, project=1)
     task.attach(fd)
     mock_new_resource.assert_called_with(files={"attached_file": fd},
                                          payload={
                                              "project": 1,
                                              "object_id": 1
                                          })
Beispiel #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')
     task = Task(rm, id=1, project=1)
     task.attach('tests/resources/tasks_list_success.json')
     mock_new_resource.assert_called_with(
         files={'attached_file': fd},
         payload={'project': 1, 'object_id': 1}
     )
Beispiel #5
0
 def test_list_attachments(self, mock_requestmaker_get):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     Task(rm, id=1).list_attachments()
     mock_requestmaker_get.assert_called_with(
         'tasks/attachments',
         query={"object_id": 1},
     )
Beispiel #6
0
 def test_list_attachments(self, mock_requestmaker_get):
     mock_requestmaker_get.return_value = MockResponse(
         200, create_mock_json('tests/resources/tasks_list_success.json'))
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     Task(rm, id=1).list_attachments()
     mock_requestmaker_get.assert_called_with('tasks/attachments',
                                              query={"object_id": 1},
                                              paginate=True)
Beispiel #7
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     task = Task(rm, id=1)
     task.add_comment('hola')
     mock_update.assert_called_with(comment='hola')
Beispiel #8
0
 def test_not_valid_type_file_attach(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     task = Task(rm, id=1, project=1)
     self.assertRaises(TaigaException, task.attach, 4)
Beispiel #9
0
 def test_not_existing_file_attach(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     task = Task(rm, id=1, project=1)
     self.assertRaises(TaigaException, task.attach, 'not-existing-file')
Beispiel #10
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     task = Task(rm, id=1)
     task.add_comment("hola")
     mock_update.assert_called_with(comment="hola")
Beispiel #11
0
 def test_not_existing_file_attach(self):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     task = Task(rm, id=1, project=1)
     self.assertRaises(TaigaException, task.attach, "not-existing-file")