def setUp(self): self.lb = Labels(user='******', repo='Hello-World')
class TestLabelsService(TestCase): def setUp(self): self.lb = Labels(user='******', repo='Hello-World') def test_GET(self, request_method): request_method.return_value = mock_response() self.lb.get('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(dict(name='bug', color='FF0000')) self.assertEqual(request_method.call_args[0], ('post', _('repos/octocat/Hello-World/labels'))) def test_CREATE_with_invalid_color(self, request_method): request_method.return_value = mock_response('post') # invalid color with self.assertRaises(ValidationError): args = {'name': 'bug', 'color': 'FF00'} self.lb.create(args) def test_UPDATE(self, request_method): request_method.return_value = mock_response('patch') self.lb.update('bug', dict(name='critical', color='FF0000')) self.assertEqual(request_method.call_args[0], ('patch', _('repos/octocat/Hello-World/labels/bug'))) def test_UPDATE_with_invalid_color(self, request_method): request_method.return_value = mock_response('post') # invalid color with self.assertRaises(ValidationError): args = {'name': 'critical', 'color': 'FF00'} self.lb.update('bug', args) def test_DELETE(self, request_method): request_method.return_value = mock_response('delete') self.lb.delete('bug') self.assertEqual(request_method.call_args[0], ('delete', _('repos/octocat/Hello-World/labels/bug'))) def test_LIST_by_issue(self, request_method): request_method.return_value = mock_response() self.lb.list_by_issue(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(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(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): request_method.return_value = mock_response() self.lb.replace_all(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(1) self.assertEqual( request_method.call_args[0], ('delete', _('repos/octocat/Hello-World/issues/1/labels'))) def test_LIST_by_milestone(self, request_method): request_method.return_value = mock_response_result() self.lb.list_by_milestone(1).all() self.assertEqual( request_method.call_args[0], ('get', _('repos/octocat/Hello-World/milestones/1/labels')))
class TestLabelsService(TestCase): def setUp(self): self.lb = Labels(user='******', repo='Hello-World') def test_GET(self, request_method): request_method.return_value = mock_response() self.lb.get('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(dict(name='bug', color='FF0000')) self.assertEqual(request_method.call_args[0], ('post', _('repos/octocat/Hello-World/labels'))) def test_CREATE_with_invalid_color(self, request_method): request_method.return_value = mock_response('post') # invalid color with self.assertRaises(ValidationError): args = {'name': 'bug', 'color': 'FF00'} self.lb.create(args) def test_UPDATE(self, request_method): request_method.return_value = mock_response('patch') self.lb.update('bug', dict(name='critical', color='FF0000')) self.assertEqual(request_method.call_args[0], ('patch', _('repos/octocat/Hello-World/labels/bug'))) def test_UPDATE_with_invalid_color(self, request_method): request_method.return_value = mock_response('post') # invalid color with self.assertRaises(ValidationError): args = {'name': 'critical', 'color': 'FF00'} self.lb.update('bug', args) def test_DELETE(self, request_method): request_method.return_value = mock_response('delete') self.lb.delete('bug') self.assertEqual(request_method.call_args[0], ('delete', _('repos/octocat/Hello-World/labels/bug'))) def test_LIST_by_issue(self, request_method): request_method.return_value = mock_response() self.lb.list_by_issue(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(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(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): request_method.return_value = mock_response() self.lb.replace_all(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(1) self.assertEqual(request_method.call_args[0], ('delete', _('repos/octocat/Hello-World/issues/1/labels'))) def test_LIST_by_milestone(self, request_method): request_method.return_value = mock_response_result() self.lb.list_by_milestone(1).all() self.assertEqual(request_method.call_args[0], ('get', _('repos/octocat/Hello-World/milestones/1/labels')))