aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/tests
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2012-04-23 17:44:10 +0200
committerStefano Rivera <stefano@rivera.za.net>2012-04-23 17:44:10 +0200
commitc7c03100fd0584b759bb75d461a12f5bcd5aabba (patch)
tree16267d3fb9919933d826ddcc8aa05f04b9b0a00f /pygithub3/tests
parent:sparkles: Release 0.3 :sparkles: (diff)
downloadpython-github3-c7c03100fd0584b759bb75d461a12f5bcd5aabba.tar.xz
python-github3-c7c03100fd0584b759bb75d461a12f5bcd5aabba.zip
Baseline Orgs API implementation
Diffstat (limited to 'pygithub3/tests')
-rw-r--r--pygithub3/tests/services/test_orgs.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/pygithub3/tests/services/test_orgs.py b/pygithub3/tests/services/test_orgs.py
new file mode 100644
index 0000000..a6416ff
--- /dev/null
+++ b/pygithub3/tests/services/test_orgs.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+import requests
+from mock import patch, Mock
+
+from pygithub3.tests.utils.core import TestCase
+from pygithub3.resources.base import json
+from pygithub3.services.orgs import Org
+from pygithub3.tests.utils.base import (mock_response, mock_response_result,
+ mock_json)
+from pygithub3.tests.utils.services import _
+
+json.dumps = Mock(side_effect=mock_json)
+json.loads = Mock(side_effect=mock_json)
+
+
+@patch.object(requests.sessions.Session, 'request')
+class TestOrgService(TestCase):
+
+ def setUp(self):
+ self.org = Org()
+
+ def test_LIST_without_user(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.org.list().all()
+ self.assertEqual(request_method.call_args[0], ('get', _('user/orgs')))
+
+ def test_LIST_with_user(self, request_method):
+ request_method.return_value = mock_response_result()
+ self.org.list('octocat').all()
+ self.assertEqual(request_method.call_args[0],
+ ('get', _('users/octocat/orgs')))
+
+ def test_GET(self, request_method):
+ request_method.return_value = mock_response()
+ self.org.get('acme')
+ self.assertEqual(request_method.call_args[0], ('get', _('orgs/acme')))
+
+ def test_UPDATE(self, request_method):
+ request_method.return_value = mock_response('patch')
+ self.org.update('acme', {'company': 'ACME Widgets'})
+ self.assertEqual(request_method.call_args[0],
+ ('patch', _('orgs/acme')))