def test_call_requests_post_with_files(self, requests_post):
     rm = RequestMaker(api_path='/v1/', host='http://host', token='f4k3')
     requests_post.return_value = MockResponse(200, '')
     file_desc = open('tests/resources/fake_objects.json')
     rm.post('nowhere', files={'sample' : file_desc})
     requests_post.assert_called_once_with(
         'http://host/v1/nowhere', files={'sample' : file_desc},
         data=None, params={},
         headers={
             'Authorization': 'Bearer f4k3',
             'x-disable-pagination': True
         }
     )
Beispiel #2
0
 def test_to_dict_method(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     fake = Fake(rm, id=1, param1='one', param2='two', param3='three')
     expected_dict = {'param1': 'one', 'param2': 'two'}
     self.assertEqual(len(fake.to_dict()), 2)
     self.assertEqual(fake.to_dict(), expected_dict)
Beispiel #3
0
 def test_add_comment(self, mock_update):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     epic = Epic(rm, id=1)
     epic.add_comment('hola')
     mock_update.assert_called_with(comment='hola')
Beispiel #4
0
 def test_not_existing_file_attach(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     epic = Epic(rm, id=1, project=1)
     self.assertRaises(TaigaException, epic.attach, 'not-existing-file')
Beispiel #5
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 #6
0
 def test_call_requests_get_with_cache(self, mock_time, requests_get):
     mock_time.return_value = 0
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_get.return_value = MockResponse(200, '')
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 1)
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 1)
     rm.get('/nowhere', cache=False)
     self.assertEqual(requests_get.call_count, 2)
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 2)
     mock_time.return_value = 61
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 3)
Beispiel #7
0
 def test_not_valid_type_file_attach(self):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     wikipage = WikiPage(rm, id=1, project=1)
     self.assertRaises(TaigaException, wikipage.attach, 4)
Beispiel #8
0
 def test_list_user_story_attributes(self, mock_list_us_attr):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.list_user_story_attributes()
     mock_list_us_attr.assert_called_with(project=1)
Beispiel #9
0
 def test_import_task(self, mock_import_task):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.import_task('Task 1', 'New')
     mock_import_task.assert_called_with(1, 'Task 1', 'New')
Beispiel #10
0
 def test_add_user_story_attribute(self, mock_new_us_attr):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.add_user_story_attribute('New Attribute')
     mock_new_us_attr.assert_called_with(1, 'New Attribute')
Beispiel #11
0
 def test_import_wikilink(self, mock_import_wikilink):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.import_wikilink('WL 1', 'href')
     mock_import_wikilink.assert_called_with(1, 'WL 1', 'href')
Beispiel #12
0
 def test_import_wikipage(self, mock_import_wikipage):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.import_wikipage('Slug 1', 'Content')
     mock_import_wikipage.assert_called_with(1, 'Slug 1', 'Content')
Beispiel #13
0
 def test_add_wikipage(self, mock_new_wikipage):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.add_wikipage('WP 1', 'Content')
     mock_new_wikipage.assert_called_with(1, 'WP 1', 'Content')
 def test_call_requests_delete(self, requests_delete):
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_delete.return_value = MockResponse(200, '')
     rm.delete('/nowhere')
     self.assertTrue(requests_delete.called)
Beispiel #15
0
 def test_add_membership(self, mock_new_membership):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.add_membership('*****@*****.**', 1)
     mock_new_membership.assert_called_with(1, '*****@*****.**', 1)
Beispiel #16
0
 def test_import_userstory(self, mock_import_userstory):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.import_user_story('US 1', 'Closed')
     mock_import_userstory.assert_called_with(1, 'US 1', 'Closed')
Beispiel #17
0
 def test_add_webhook(self, mock_new_webhook):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.add_webhook('New Webhook', 'webhook-url', 'webhook-key')
     mock_new_webhook.assert_called_with(1, 'New Webhook', 'webhook-url',
                                         'webhook-key')
 def test_call_requests_delete(self, requests_delete):
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_delete.return_value = MockResponse(200, '')
     rm.delete('/nowhere')
     self.assertTrue(requests_delete.called)
Beispiel #19
0
 def test_list_webhooks(self, mock_list_webhooks):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.list_webhooks()
     mock_list_webhooks.assert_called_with(project=1)
Beispiel #20
0
 def test_issue_creation(self, mock_requestmaker_post):
     mock_requestmaker_post.return_value = MockResponse(200,
         create_mock_json('tests/resources/issue_details_success.json'))
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     issue = Issues(rm).create(1, 2, 3, 4, 5, 6)
     self.assertTrue(isinstance(issue, Issue))
Beispiel #21
0
 def test_issues_stats(self, mock_requestmaker_get):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.issues_stats()
     mock_requestmaker_get.assert_called_with(
         '/{endpoint}/{id}/issues_stats', endpoint='projects', id=1)
Beispiel #22
0
 def test_call_requests_get_with_cache(self, mock_time, requests_get):
     mock_time.return_value = 0
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_get.return_value = MockResponse(200, '')
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 1)
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 1)
     rm.get('/nowhere', cache=False)
     self.assertEqual(requests_get.call_count, 2)
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 2)
     mock_time.return_value = 61
     rm.get('/nowhere', cache=True)
     self.assertEqual(requests_get.call_count, 3)
Beispiel #23
0
 def test_create_user_story_status(self, mock_new_resource):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     mock_new_resource.return_value = UserStoryStatus(rm)
     UserStoryStatuses(rm).create(1, "USS 1")
     mock_new_resource.assert_called_with(payload={"project": 1, "name": "USS 1"})
Beispiel #24
0
 def test_me(self, mock_user_get):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     mock_user_get.return_value = User(rm, full_name="Andrea")
     api = TaigaAPI(token="f4k3")
     user = api.me()
     self.assertEqual(user.full_name, "Andrea")
Beispiel #25
0
 def test_call_model_base_get_element(self, mock_requestmaker_get):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     fakes = Fakes(rm)
     fakes.get(1)
     mock_requestmaker_get.assert_called_once_with("/{endpoint}/{id}", endpoint="fakes", id=1)
Beispiel #26
0
 def test_not_valid_type_file_attach(self):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     epic = Epic(rm, id=1, project=1)
     self.assertRaises(TaigaException, epic.attach, 4)
Beispiel #27
0
 def test_call_model_base_delete_element(self, mock_requestmaker_delete):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     fake = Fake(rm, id=1, param1="one", param2="two")
     fake.delete()
     mock_requestmaker_delete.assert_called_once_with("/{endpoint}/{id}", endpoint="fakes", id=1)
Beispiel #28
0
 def test_me(self, mock_user_get):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     mock_user_get.return_value = User(rm, full_name='Andrea')
     api = TaigaAPI(token='f4k3')
     user = api.me()
     self.assertEqual(user.full_name, 'Andrea')
Beispiel #29
0
 def test_call_model_base_delete_element_from_list(self, mock_requestmaker_delete):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     fakes = Fakes(rm)
     fakes.delete(1)
     mock_requestmaker_delete.assert_called_once_with("/{endpoint}/{id}", endpoint="fakes", id=1)
 def test_call_requests_delete_raise_exception_on_requests_error(
         self, requests_delete):
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_delete.side_effect = requests.RequestException()
     self.assertRaises(taiga.exceptions.TaigaRestException, rm.delete,
                       '/nowhere')
Beispiel #31
0
 def test_to_dict_method(self):
     rm = RequestMaker("/api/v1", "fakehost", "faketoken")
     fake = Fake(rm, id=1, param1="one", param2="two", param3="three")
     expected_dict = {"param1": "one", "param2": "two"}
     self.assertEqual(len(fake.to_dict()), 2)
     self.assertEqual(fake.to_dict(), expected_dict)
 def test_call_requests_post_raise_exception_on_bad_response(
         self, requests_post):
     rm = RequestMaker(api_path='/', host='host', token='f4k3')
     requests_post.return_value = MockResponse(400, '')
     self.assertRaises(taiga.exceptions.TaigaRestException, rm.post,
                       '/nowhere')
Beispiel #33
0
 def test_import_issue(self, mock_import_issue):
     rm = RequestMaker('/api/v1', 'fakehost', 'faketoken')
     project = Project(rm, id=1)
     project.import_issue('Issue 1', 1, 2, 3, 4)
     mock_import_issue.assert_called_with(1, 'Issue 1', 1, 2, 3, 4)