aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/tests
diff options
context:
space:
mode:
authorAlejandro Gómez <alejandroogomez@gmail.com>2012-04-27 13:50:25 +0200
committerAlejandro Gómez <alejandroogomez@gmail.com>2012-05-27 19:54:29 +0200
commit837c07729c089b8c5fdf3828cedff054b0cf1dde (patch)
tree3afcb0ab80782c22d74baeae803a369c8886eea0 /pygithub3/tests
parentLabels and Milestones services added (diff)
downloadpython-github3-837c07729c089b8c5fdf3828cedff054b0cf1dde.tar.xz
python-github3-837c07729c089b8c5fdf3828cedff054b0cf1dde.zip
test Label validation errors
Diffstat (limited to 'pygithub3/tests')
-rw-r--r--pygithub3/tests/resources/test_issues.py17
-rw-r--r--pygithub3/tests/services/test_issues.py22
2 files changed, 39 insertions, 0 deletions
diff --git a/pygithub3/tests/resources/test_issues.py b/pygithub3/tests/resources/test_issues.py
new file mode 100644
index 0000000..0bef3c1
--- /dev/null
+++ b/pygithub3/tests/resources/test_issues.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+from unittest import TestCase
+
+from pygithub3.resources.issues import Label
+
+
+class TestLabel(TestCase):
+ def test_is_valid_color(self):
+ valid_colors = ['BADA55', 'FFFFFF', '45DFCA']
+ for color in valid_colors:
+ self.assertTrue(Label.is_valid_color(color))
+
+ invalid_colors = ['BDA55', '#FFAABB', 'FFf']
+ for color in invalid_colors:
+ self.assertFalse(Label.is_valid_color(color))
diff --git a/pygithub3/tests/services/test_issues.py b/pygithub3/tests/services/test_issues.py
index 33ce754..4672bdb 100644
--- a/pygithub3/tests/services/test_issues.py
+++ b/pygithub3/tests/services/test_issues.py
@@ -4,6 +4,7 @@
import requests
from mock import patch, Mock
+from pygithub3.exceptions import ValidationError
from pygithub3.tests.utils.core import TestCase
from pygithub3.resources.base import json
from pygithub3.services.issues import Issue, Comments, Events, Labels, Milestones
@@ -133,12 +134,33 @@ class TestLabelsService(TestCase):
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={'user': 'octocat',
+ 'repo': 'Hello-world',
+ 'name': 'bug',
+ 'color': 'FF00',}
+ self.lb.create(**args)
+
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_UPDATE_with_invalid_color(self, request_method):
+ request_method.return_value = mock_response('post')
+ # invalid color
+ with self.assertRaises(ValidationError):
+ args={'user': 'octocat',
+ 'repo': 'Hello-world',
+ 'name': 'bug',
+ 'new_name': 'critical',
+ 'color': 'FF00',}
+ self.lb.update(**args)
+
def test_DELETE(self, request_method):
request_method.return_value = mock_response('delete')
self.lb.delete('octocat', 'Hello-World', 'bug')