|
6 | 6 |
|
7 | 7 | from pygithub3.tests.utils.core import TestCase |
8 | 8 | from pygithub3.resources.base import json |
9 | | -from pygithub3.services.gists import Gist |
| 9 | +from pygithub3.services.gists import Gist, Comments |
10 | 10 | from pygithub3.tests.utils.base import (mock_response, mock_response_result, |
11 | 11 | mock_json) |
12 | 12 | from pygithub3.tests.utils.services import _ |
@@ -91,3 +91,40 @@ def test_DELETE(self, request_method): |
91 | 91 | self.gs.delete(1) |
92 | 92 | self.assertEqual(request_method.call_args[0], |
93 | 93 | ('delete', _('gists/1'))) |
| 94 | + |
| 95 | + |
| 96 | +@patch.object(requests.sessions.Session, 'request') |
| 97 | +class TestCommentService(TestCase): |
| 98 | + |
| 99 | + def setUp(self): |
| 100 | + self.cs = Comments() |
| 101 | + |
| 102 | + def test_LIST(self, request_method): |
| 103 | + request_method.return_value = mock_response_result() |
| 104 | + self.cs.list(1).all() |
| 105 | + self.assertEqual(request_method.call_args[0], |
| 106 | + ('get', _('gists/1/comments'))) |
| 107 | + |
| 108 | + def test_GET(self, request_method): |
| 109 | + request_method.return_value = mock_response() |
| 110 | + self.cs.get(1) |
| 111 | + self.assertEqual(request_method.call_args[0], |
| 112 | + ('get', _('gists/comments/1'))) |
| 113 | + |
| 114 | + def test_CREATE(self, request_method): |
| 115 | + request_method.return_value = mock_response('post') |
| 116 | + self.cs.create(1, dict(body='comment')) |
| 117 | + self.assertEqual(request_method.call_args[0], |
| 118 | + ('post', _('gists/1/comments'))) |
| 119 | + |
| 120 | + def test_UPDATE(self, request_method): |
| 121 | + request_method.return_value = mock_response('patch') |
| 122 | + self.cs.update(1, dict(body='new_comment')) |
| 123 | + self.assertEqual(request_method.call_args[0], |
| 124 | + ('patch', _('gists/comments/1'))) |
| 125 | + |
| 126 | + def test_DELETE(self, request_method): |
| 127 | + request_method.return_value = mock_response('delete') |
| 128 | + self.cs.delete(1) |
| 129 | + self.assertEqual(request_method.call_args[0], |
| 130 | + ('delete', _('gists/comments/1'))) |
0 commit comments