diff options
author | 2012-04-26 21:00:13 +0200 | |
---|---|---|
committer | 2012-05-27 19:54:28 +0200 | |
commit | 8972834a85a17ebbeb326a9d4493725d53913e33 (patch) | |
tree | ba7b2529a2e0cea900f18a3a3d275178d394cc63 /pygithub3/tests | |
parent | Fix some issues resources (diff) | |
download | python-github3-8972834a85a17ebbeb326a9d4493725d53913e33.tar.xz python-github3-8972834a85a17ebbeb326a9d4493725d53913e33.zip |
Labels and Milestones services added
Diffstat (limited to 'pygithub3/tests')
-rw-r--r-- | pygithub3/tests/services/test_issues.py | 107 | ||||
-rw-r--r-- | pygithub3/tests/services/test_repos.py | 12 |
2 files changed, 117 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'))) diff --git a/pygithub3/tests/services/test_repos.py b/pygithub3/tests/services/test_repos.py index e21d474..a07635a 100644 --- a/pygithub3/tests/services/test_repos.py +++ b/pygithub3/tests/services/test_repos.py @@ -134,6 +134,18 @@ class TestRepoService(TestCase): self.assertEqual(request_method.call_args[0], ('get', _('repos/octocat/octocat_repo/branches'))) + def test_LIST_labels(self, request_method): + request_method.return_value = mock_response_result() + self.rs.list_labels().all() + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/octocat_repo/labels'))) + + def test_LIST_milestones(self, request_method): + request_method.return_value = mock_response_result() + self.rs.list_milestones().all() + self.assertEqual(request_method.call_args[0], + ('get', _('repos/octocat/octocat_repo/milestones'))) + @patch.object(requests.sessions.Session, 'request') class TestCollaboratorsService(TestCase): |