diff options
Diffstat (limited to 'pygithub3/tests/services/test_issues.py')
-rw-r--r-- | pygithub3/tests/services/test_issues.py | 107 |
1 files changed, 105 insertions, 2 deletions
diff --git a/pygithub3/tests/services/test_issues.py b/pygithub3/tests/services/test_issues.py index dfc56ca..33ce754 100644 --- a/pygithub3/tests/services/test_issues.py +++ b/pygithub3/tests/services/test_issues.py @@ -6,7 +6,7 @@ from mock import patch, Mock from pygithub3.tests.utils.core import TestCase from pygithub3.resources.base import json -from pygithub3.services.issues import Issue, Comments, Events +from pygithub3.services.issues import Issue, Comments, Events, Labels, Milestones from pygithub3.tests.utils.base import (mock_response, mock_response_result, mock_json) from pygithub3.tests.utils.services import _ @@ -112,4 +112,107 @@ class TestEventsService(TestCase): request_method.return_value = mock_response() self.ev.get('octocat', 'Hello-World', 1) self.assertEqual(request_method.call_args[0], - ('get', _('repos/octocat/Hello-World/issues/events/1')))
\ No newline at end of file + ('get', _('repos/octocat/Hello-World/issues/events/1'))) + + +@patch.object(requests.sessions.Session, 'request') +class TestLabelsService(TestCase): + + def setUp(self): + self.lb = Labels() + + def test_GET(self, request_method): + request_method.return_value = mock_response() + self.lb.get('octocat', 'Hello-World', 'bug') + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/Hello-World/labels/bug'))) + + def test_CREATE(self, request_method): + request_method.return_value = mock_response('post') + self.lb.create('octocat', 'Hello-World', 'bug', 'FF0000') + self.assertEqual(request_method.call_args[0], + ('post', _('repos/octocat/Hello-World/labels'))) + + def test_UPDATE(self, request_method): + request_method.return_value = mock_response('patch') + self.lb.update('octocat', 'Hello-World', 'bug', 'critical', 'FF0000') + self.assertEqual(request_method.call_args[0], + ('patch', _('repos/octocat/Hello-World/labels/bug'))) + + def test_DELETE(self, request_method): + request_method.return_value = mock_response('delete') + self.lb.delete('octocat', 'Hello-World', 'bug') + self.assertEqual(request_method.call_args[0], + ('delete', _('repos/octocat/Hello-World/labels/bug'))) + + def test_LIST_by_repo(self, request_method): + request_method.return_value = mock_response() + self.lb.list_by_repo('octocat', 'Hello-World') + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/Hello-World/labels'))) + + def test_LIST_by_issue(self, request_method): + request_method.return_value = mock_response() + self.lb.list_by_issue('octocat', 'Hello-World', 1) + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/Hello-World/issues/1/labels'))) + + def test_ADD_to_issue(self, request_method): + request_method.return_value = mock_response('post') + self.lb.add_to_issue('octocat', 'Hello-World', 1, ['bug', 'critical']) + self.assertEqual(request_method.call_args[0], + ('post', _('repos/octocat/Hello-World/issues/1/labels'))) + + def test_REMOVE_from_issue(self, request_method): + request_method.return_value = mock_response('delete') + self.lb.remove_from_issue('octocat', 'Hello-World', 1, 'bug') + self.assertEqual(request_method.call_args[0], + ('delete', _('repos/octocat/Hello-World/issues/1/labels/bug'))) + + def test_REPLACE_all(self, request_method): + self.lb.replace_all('octocat', 'Hello-World', 1, ['bug', 'critical']) + self.assertEqual(request_method.call_args[0], + ('put', _('repos/octocat/Hello-World/issues/1/labels'))) + + def test_REMOVE_all(self, request_method): + request_method.return_value = mock_response('delete') + self.lb.remove_all('octocat', 'Hello-World', 1) + self.assertEqual(request_method.call_args[0], + ('delete', _('repos/octocat/Hello-World/issues/1/labels'))) + + +@patch.object(requests.sessions.Session, 'request') +class TestMilestonesService(TestCase): + + def setUp(self): + self.mi = Milestones() + + def test_LIST_by_repo(self, request_method): + request_method.return_value = mock_response_result() + self.mi.list('octocat', 'Hello-World').all() + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/Hello-World/milestones'))) + + def test_GET(self, request_method): + request_method.return_value = mock_response() + self.mi.get('octocat', 'Hello-World', 1) + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/Hello-World/milestones/1'))) + + def test_CREATE(self, request_method): + request_method.return_value = mock_response('post') + self.mi.create('octocat', 'Hello-World', 'title') + self.assertEqual(request_method.call_args[0], + ('post', _('repos/octocat/Hello-World/milestones'))) + + def test_UPDATE(self, request_method): + request_method.return_value = mock_response('patch') + self.mi.update('octocat', 'Hello-World', 1, 'critical') + self.assertEqual(request_method.call_args[0], + ('patch', _('repos/octocat/Hello-World/milestones/1'))) + + def test_DELETE(self, request_method): + request_method.return_value = mock_response('delete') + self.mi.delete('octocat', 'Hello-World', 1) + self.assertEqual(request_method.call_args[0], + ('delete', _('repos/octocat/Hello-World/milestones/1'))) |