|
4 | 4 | import requests |
5 | 5 | from mock import patch, Mock |
6 | 6 |
|
| 7 | +from pygithub3.exceptions import ValidationError |
7 | 8 | from pygithub3.tests.utils.core import TestCase |
8 | 9 | from pygithub3.resources.base import json |
9 | 10 | from pygithub3.services.issues import Issue, Comments, Events, Labels, Milestones |
@@ -133,12 +134,33 @@ def test_CREATE(self, request_method): |
133 | 134 | self.assertEqual(request_method.call_args[0], |
134 | 135 | ('post', _('repos/octocat/Hello-World/labels'))) |
135 | 136 |
|
| 137 | + def test_CREATE_with_invalid_color(self, request_method): |
| 138 | + request_method.return_value = mock_response('post') |
| 139 | + # invalid color |
| 140 | + with self.assertRaises(ValidationError): |
| 141 | + args={'user': 'octocat', |
| 142 | + 'repo': 'Hello-world', |
| 143 | + 'name': 'bug', |
| 144 | + 'color': 'FF00',} |
| 145 | + self.lb.create(**args) |
| 146 | + |
136 | 147 | def test_UPDATE(self, request_method): |
137 | 148 | request_method.return_value = mock_response('patch') |
138 | 149 | self.lb.update('octocat', 'Hello-World', 'bug', 'critical', 'FF0000') |
139 | 150 | self.assertEqual(request_method.call_args[0], |
140 | 151 | ('patch', _('repos/octocat/Hello-World/labels/bug'))) |
141 | 152 |
|
| 153 | + def test_UPDATE_with_invalid_color(self, request_method): |
| 154 | + request_method.return_value = mock_response('post') |
| 155 | + # invalid color |
| 156 | + with self.assertRaises(ValidationError): |
| 157 | + args={'user': 'octocat', |
| 158 | + 'repo': 'Hello-world', |
| 159 | + 'name': 'bug', |
| 160 | + 'new_name': 'critical', |
| 161 | + 'color': 'FF00',} |
| 162 | + self.lb.update(**args) |
| 163 | + |
142 | 164 | def test_DELETE(self, request_method): |
143 | 165 | request_method.return_value = mock_response('delete') |
144 | 166 | self.lb.delete('octocat', 'Hello-World', 'bug') |
|
0 commit comments