8000 Migrated update_label test to tests/{integration/unit} · pythonthings/github3.py@f67e02d · GitHub
[go: up one dir, main page]

Skip to content

Commit f67e02d

Browse files
Migrated update_label test to tests/{integration/unit}
1 parent 50a612e commit f67e02d

File tree

4 files changed

+45
-20
lines changed

4 files changed

+45
-20
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA62YTW/jNhCG/4qhax3TH3GyK6DY9tT2toftpReDlmiLiCQKJGXDEfLf+w4pyZIX9UfYi2HLnIcvh5zRDJtIplG8el3MXxeLaVTyQkRxtJc2q7erWXWKptGuzvNN+4eR+4IfpK7N8pmNRqljKXQUN1Gu9rIEYzgUFJpm+Tz/sppPI37glutNrXOMy6ytTMyYf2hmnloboRNVWlHaWaIKVjNv/O3w6wq0vW4ZhI3w4IJVyZbjjQEz7EJQZov8QoKf2plcDN6pPFdHUC5F35qI9ZbkSUeR5f6TFFg2TNlMwHdY0gc5Qhr7uChn1WADjd3IlDgGG6JF+rCw1g6yaP8/GqZFpRyw3ppEy8pKVT4ucGQNmtJ7Xsp3/jkarA0gJO1xKc4K1uKAs/i4uTdrWKXlgScnco0WiZAHOPuTyAt7EO2porD9G4eCXC+t2PC0oDDc8dyIj2nkprcY5B5MEXX3nv5xmKei31VM+P1kM1VOcrnVXJ8mO6UnEjGrdzzBWZ0ckUYmOK6TP6T9s95Ofv/+14GiF+PeeiVXI9c5fxSMYzlEurEnVxEITwAg6U2cgjhk3zB8tvGUINT5Vmlu1a2kcV3gCNSw4U86S1bwIki4AwCUKRXmSQcASBpTi7uO9vWFO45hXfyUdbH1Ke+eqLmO9gRo5QZ5vhQiyIM9pGFdVkY4lEkWhu0YDfPf3G7zfZBUsgdmm6ttEAcvSuYgDTMZ9+8huwlVR1RijKBa7IKlEqOHWh24304mQXokXoIWWx+ks2OwpvVozst9zfdh1B6CXadX9Z6/3yxirsfOmQIkVWhabuvwJHfmkFJfOyDew1x6xpyhriC5XubccMCgsHEuKAp5qy64TmwRo2P/P2DpnF6i6fftMua2XGI07JyTfdJv6SHebbN+p3M4R9sOBB2JjsGaXypuM8pcmKriWoSIbhGs2XIUW7PZrMkEd2V1IXRgBHsCUFwnGarGEJ1Nx0DVU3DrqvUdyUxRveeKp0G+7SEA+m0M0eoJw/2v0IcGCXSAIbGQuTBWlWE59kwZsktl5U4m93Qs18NtBGq+GVkmYsrzfIpTa2UicY5Ra9MuouAUYR7yBCwD1wC+U8kFjnSQ17XwjIb5TjMVVa5OwVlogKEg1gLdTbrhFl3Jcr5YPs1XT4vVj8XXeP0lXq/+wZi6SkdjXp7mi6fl8sfiJZ4vcTdBY6raZANMP2QVr+fx85qGIK225xrfcG+BT9yV/HRpMOhT6CoChsZkZ8Pfzmbxf1yqtGZJjgN6EUn3z3m4fNfdNoXUTBWiQu3RXs/0q1xVpxk8naKnS1ViZmisGa1MvmPo63q1HFUZiapL7Mfz+us0OnKLghjv8+HDrjrpO0mampuNj/0otrqmVhVPzrll8PAo3+S5ocUokmw6M98attMtXl6RjKXWqr12KpELcK1QibKdrRcGsb4pjJ3RYAiWMlhJu7BU7Hid240v0rGSFN1Frio6TEIXWApdgNDF2LAj9yetk0qJyX9Hp14Ke0RT2ulxIoYFUbui5evHvyw07pa8EwAA", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "repo", "etag": "W/\"555334bb9c3228b0acc7e56f0cd3d381\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4997", "x-served-by": "065b43cd9674091fec48a221b420fbb3", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "97E45D32:175B2:4A4F01A:56A34F7C", "access-control-allow-credentials": "true", "last-modified": "Fri, 22 Jan 2016 16:02:24 GMT", "date": "Sat, 23 Jan 2016 10:01:32 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453546696"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2016-01-23T10:01:33"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/labels/impossible"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA1WMWwqAIBAA77Lf4UZP8DYaYgtriqtBRHdP6KvfmWFuqJlBw15KEo1oEilPZa9WbTFgdikKCvlgTspVhgk/O6p0IRvrWJBCi4QsO+jgMMG1349tkWNusO8Xu87wvINM31V1AAAA", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "", "etag": "W/\"4db7d22c7ff16541d42880db14dc04a5\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4996", "x-served-by": "bae57931a6fe678a3dffe9be8e7819c8", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "97E45D32:175B2:4A4F05F:56A34F7C", "access-control-allow-credentials": "true", "last-modified": "Sat, 23 Jan 2016 09:58:57 GMT", "date": "Sat, 23 Jan 2016 10:01:32 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453546696"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/labels/impossible"}, "recorded_at": "2016-01-23T10:01:33"}, {"request": {"body": {"string": "{\"color\": \"006b75\", \"name\": \"possible\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "39", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "PATCH", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/labels/impossible"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA02MWwqAIBAA77Lf4UZP8DYaYgtriqtBRHdP6KffmWFuqJlBw15KEo1oEilPZa9WbTFgdikKCvlgTspVhgk/O6p0IRvrWLAlQpYddHCY4NrtR7bIMTfU94tdZ3hecHya1XEAAAA=", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.v3; param=full; format=json", "x-oauth-scopes": "admin:public_key, gist, repo, user", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "x-accepted-oauth-scopes": "", "etag": "W/\"90fa0f5d946b5a1addcc47e826afae8c\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4995", "x-served-by": "3e3b9690823fb031da84658eb58aa83b", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "97E45D32:175B2:4A4F091:56A34F7C", "access-control-allow-credentials": "true", "date": "Sat, 23 Jan 2016 10:01:32 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1453546696"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/labels/impossible"}, "recorded_at": "2016-01-23T10:01:33"}], "recorded_with": "betamax/0.5.0"}

tests/integration/test_repos_repo.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,14 @@ def test_tree(self):
10081008
tree = repository.tree('52a3f30e05cf434285e775979f01f1a8355049a7')
10091009

10101010
assert isinstance(tree, github3.git.Tree)
1011+
1012+
def test_update_label(self):
1013+
"""Test the ability to update a label on a repository."""
1014+
self.token_login()
1015+
cassette_name = self.cassette_name('update_label')
1016+
with self.recorder.use_cassette(cassette_name):
1017+
repository = self.gh.repository('sigmavirus24', 'github3.py')
1018+
updated_label = repository.update_label('impossible', '006b75',
1019+
new_name='possible')
1020+
1021+
assert updated_label is True

tests/test_repos.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@ def setUp(self):
1818
def test_repr(self):
1919
assert repr(self.repo) == '<Repository [sigmavirus24/github3.py]>'
2020

21-
def test_update_label(self):
22-
self.response('label')
23-
self.patch(self.api + 'labels/Bug')
24-
self.conf = {'data': {'name': 'big_bug', 'color': 'fafafa'}}
25-
26-
self.assertRaises(github3.GitHubError, self.repo.update_label,
27-
'foo', 'bar')
28-
self.not_called()
29-
30-
self.login()
31-
with mock.patch.object(repos.Repository, 'label') as l:
32-
l.return_value = None
33-
assert self.repo.update_label('foo', 'bar') is False
34-
self.not_called()
35-
36-
with mock.patch.object(repos.Repository, 'label') as l:
37-
l.return_value = github3.issues.label.Label(load('label'), self.g)
38-
assert self.repo.update_label('big_bug', 'fafafa')
39-
40-
self.mock_assertions()
4121

4222
def test_equality(self):
4323
assert self.repo == repos.Repository(load('repo'))

tests/unit/test_repos_repo.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,39 @@ def test_tree_required_sha(self):
874874

875875
assert self.session.get.called is False
876876

877+
def test_update_label(self):
878+
"""Verify the request for updating a label."""
879+
with mock.patch.object(Repository, 'label') as mocked_label:
880+
mocked_label.return_value.update.return_value = True
881+
update = self.instance.update_label('easy', 'ffffff',
882+
new_name='hard')
883+
assert update is True
884+
mocked_label.assert_called_once_with('easy')
885+
mocked_label.return_value.update.assert_called_once_with(
886+
'hard',
887+
'ffffff'
888+
)
889+
890+
def test_update_label_missing_new_name(self):
891+
"""Verify the request for updating a label."""
892+
with mock.patch.object(Repository, 'label') as mocked_label:
893+
mocked_label.return_value.update.return_value = True
894+
update = self.instance.update_label('easy', 'ffffff')
895+
assert update is True
896+
mocked_label.assert_called_once_with('easy')
897+
mocked_label.return_value.update.assert_called_once_with(
898+
'easy',
899+
'ffffff'
900+
)
901+
902+
def test_update_label_required_existing_label(self):
903+
"""Verify the request for updating a label."""
904+
with mock.patch.object(Repository, 'label') as mocked_label:
905+
mocked_label.return_value = None
906+
update = self.instance.update_label('easy', 'ffffff',
907+
new_name='hard')
908+
assert update is False
909+
877910

878911
class TestRepositoryIterator(helper.UnitIteratorHelper):
879912

0 commit comments

Comments
 (0)
0