Beispiel #1
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     user_story = UserStory(rm, id=1)
     user_story.add_comment('hola')
     mock_update.assert_called_with(
         comment='hola'
     )
 def test_add_comment(self, mock_update):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     user_story = UserStory(rm, id=1)
     user_story.add_comment('hola')
     mock_update.assert_called_with(
         comment='hola'
     )
Beispiel #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")
     userstory = UserStory(rm, id=1, project=1)
     userstory.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_add_task(self, mock_requestmaker_post):
     mock_requestmaker_post.return_value = MockResponse(200,
         create_mock_json('tests/resources/task_details_success.json'))
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     userstory = UserStory(rm, id=1, project=1)
     task = userstory.add_task('', '')
     self.assertTrue(isinstance(task, Task))
 def test_list_tasks(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')
     userstory = UserStory(rm, id=1, project=1)
     tasks = userstory.list_tasks()
     self.assertEqual(len(tasks), 2)
Beispiel #6
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")
     userstory = UserStory(rm, id=1, project=1)
     userstory.attach("tests/resources/tasks_list_success.json")
     mock_new_resource.assert_called_with(files={"attached_file": fd}, payload={"project": 1, "object_id": 1})
Beispiel #7
0
 def test_add_task(self, mock_requestmaker_post):
     mock_requestmaker_post.return_value = MockResponse(
         200, create_mock_json('tests/resources/task_details_success.json'))
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     userstory = UserStory(rm, id=1, project=1)
     task = userstory.add_task('', '')
     self.assertTrue(isinstance(task, Task))
Beispiel #8
0
 def test_list_tasks(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')
     userstory = UserStory(rm, id=1, project=1)
     tasks = userstory.list_tasks()
     self.assertEqual(len(tasks), 2)
 def test_open_file_attach(self, mock_new_resource):
     fd = open('tests/resources/tasks_list_success.json')
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     userstory = UserStory(rm, id=1, project=1)
     userstory.attach(fd)
     mock_new_resource.assert_called_with(
         files={'attached_file': fd},
         payload={'project': 1, 'object_id': 1}
     )
Beispiel #10
0
 def test_open_file_attach(self, mock_new_resource):
     fd = open('tests/resources/tasks_list_success.json')
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     userstory = UserStory(rm, id=1, project=1)
     userstory.attach(fd)
     mock_new_resource.assert_called_with(
         files={'attached_file': fd},
         payload={'project': 1, 'object_id': 1}
     )
Beispiel #11
0
 def test_list_attachments(self, mock_requestmaker_get):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     UserStory(rm, id=1).list_attachments()
     mock_requestmaker_get.assert_called_with(
         'userstories/attachments',
         query={"object_id": 1},
     )
Beispiel #12
0
 def test_create_user_story(self, mock_new_resource):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     mock_new_resource.return_value = UserStory(rm)
     UserStories(rm).create(1, 'UserStory 1')
     mock_new_resource.assert_called_with(
         payload={'project': 1, 'subject': 'UserStory 1'}
     )
Beispiel #13
0
 def test_list_attachments(self, mock_requestmaker_get):
     mock_requestmaker_get.return_value = MockResponse(
         200, create_mock_json("tests/resources/userstories_list_success.json")
     )
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     UserStory(rm, id=1).list_attachments()
     mock_requestmaker_get.assert_called_with("userstories/attachments", query={"object_id": 1}, paginate=True)
Beispiel #14
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     user_story = UserStory(rm, id=1)
     user_story.add_comment("hola")
     mock_update.assert_called_with(comment="hola")
Beispiel #15
0
 def test_not_valid_type_file_attach(self):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     userstory = UserStory(rm, id=1, project=1)
     self.assertRaises(TaigaException, userstory.attach, 4)
Beispiel #16
0
 def test_create_user_story(self, mock_new_resource):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     mock_new_resource.return_value = UserStory(rm)
     UserStories(rm).create(1, "UserStory 1")
     mock_new_resource.assert_called_with(payload={"project": 1, "subject": "UserStory 1"})
Beispiel #17
0
 def test_not_existing_file_attach(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     userstory = UserStory(rm, id=1, project=1)
     self.assertRaises(TaigaException, userstory.attach, 'not-existing-file')
Beispiel #18
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     user_story = UserStory(rm, id=1)
     user_story.add_comment("hola")
     mock_update.assert_called_with(comment="hola")