Commits

Ian Cordasco  committed b8ac362

Add Issue#iter_labels and integration test

  • Participants
  • Parent commits 9a74bc0
  • Branches new-pagination

Comments (0)

Files changed (3)

File github3/issues/issue.py

         url = self._build_url('events', base_url=self._api)
         return self._iter(int(number), url, IssueEvent)
 
+    def iter_labels(self, number=-1, etag=None):
+        """Iterate over the labels associated with this issue.
+
+        :param int number: (optional), number of labels to return. Default: -1
+            returns all labels applied to this issue.
+        :param str etag: (optional), ETag from a previous request to the same
+            endpoint
+        """
+        url = self._build_url('labels', base_url=self._api)
+        return self._iter(int(number), url, Label, etag=etag)
+
     @requires_auth
     def remove_label(self, name):
         """Removes label ``name`` from this issue.

File tests/cassettes/Issue_iter_labels.json

+{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA62YTZOjNhCG/4qLazyWMf7kstnTJrc9bC65uAQIoxpAlCTs8lDz3/MKYQxOxR+jXFw2Vj961eoW3Wo8nnhhsPHnG9+feiUtmBd6B66zOgpm1dmbemmd5/vuD8UPBT1yWavFkoxGiVPJpBc2Xi4OvARjOBQUM81iOd8G86lHj1RTua9ljnGZ1pUKCbEP1cxSa8VkLErNSj2LRUFqYo2/AXWQHcAwvdhfboPVOtnu0t1ixda7hb/ZRoz5yS6gcbqBwc1EFe8msWTMpMiN2kwX+Y0+q6s1uRmcijwXJ1BuV/RoItJbGje3FF4evkiBZUOEzhgciyV9GkdxpV8X1Vo12F2l9zwxHIXdkix5WVhnB1kmOD4bIlklWmAdqVjySnNRvi5wZA2akAda8g/6NRqsFSBG2utSWitYsyMC9XVza9aQSvIjjc/GNZLFjB/h7C8ib+xB1OfK5PRfCArjeq7ZniaFydGU5op9Tr12eo1B7YM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x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"3dfc063103fa9b863e681151a20cb754\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "59", "x-served-by": "d818ddef80f4c7d10683dd483558952a", "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": "48A0C5F1:2E4E:4334415:53586757", "access-control-allow-credentials": "true", "last-modified": "Wed, 23 Apr 2014 01:46:44 GMT", "date": "Thu, 24 Apr 2014 01:22:31 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1398306151"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2014-04-24T01:22:12"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/issues/187"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA71WTY/bNhD9KwSPiWNS8rfgOGjRHnLrIUWB1oVDiWOZAEUKJGXHMfzfO5RsZ70JdtcbozAMSCPOm3mPM0MeaOM0zegmhNpnjIla9UsVNk3eL2zFHNTWM6/KSmyVa3w6ZN3XQb/eM+V9A54l0wntUS1y0H51FzjWgR2YERUcERxzqcCEe8Gf4RAZtnfE7cAQdRMq/UiKB6q+SE8laZaOUj5J02mPmqbKwdEMte7RoIIG3LTfbNFEWUjYWbIWRbCOiCZsMIHGx9UHqm2pDC59GBI/t+BDPh3wHhVbEYR7vHGt0Z9qIaIV1gSM1ZZFwzrnDwhVuhNAxKRFMpwORmM5na1n6QjGszSZTHOARM4GoljHQnmyQmKk64K7SU1cvLZa2x2iPGZ0XdnfB2IXzwuKMuUrUdDzwGzYAAqLlGINl8o/V8A/SKr1OmDX+bBSMuJ43BgH8ubETn6Y1s5gRoe2uVvAJveFU3VQ1tyu2pU3ollXCqO+itehobdHkHbu3Myw9ULvl/T0D6Tu3A6sdmorin2UxkEBaotivxLykT8ihn0dW/fP2J8ovQqwErKKPboW2sPxPEhp9s/h6VZ5ejZ3E5T92pQYJo5RDNq9FFZbnA0UkkSmCT327hHnd+H33wKd3s6ReAoJL+4VyWyEKSDOvQcBr4wXhhLwd6e4fwjl3u7waHz7UZhvkaOZRDPpzBfOfDblnB7/bRs2RPltDdFReBzGBtBiGq17tFIafLDmYricTtkATz4H6C1XIiBCypPhO56849NPnGd8lI1GfyNiU8vv1yTJpzTJhtNslMQ1hbb+BNOFza3cr+I5hbjzejEXZONg/X55uQoEZBXAtQM/d0qYVdG4oAyLfBrPhikfj0eDZJJO+IzzyWC8pIvzPeJ25zkTC1IJCaQCgqS1+grkIzHYeY7I00kHkqhA5lAtRCBC6znDx/6c1YulWRqk8Yv2Ni5BfaUnwZIciJBYBfEZxzGZF1bC4nyJaY/HOWttZN2YIk6tPvkLWgAiyBp2pLRWEvgiqho3KuKcs4mB4ta3CaDGraQBvsSter0QLxShE6AfeT9L+oruT/A8cfw/6L3p+L3pLx1SxP+zJD9fsfz8czRP7ZLvuy49/gebm/VMKAsAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"3c7806adc30a3c70862232625739e60e\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "58", "x-served-by": "132026e9262a0093e437f99db5f1e499", "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": "48A0C5F1:2E4E:433444C:53586757", "access-control-allow-credentials": "true", "last-modified": "Thu, 24 Apr 2014 00:44:08 GMT", "date": "Thu, 24 Apr 2014 01:22:31 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1398306151"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/issues/187"}, "recorded_at": "2014-04-24T01:22:12"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/issues/187/labels?per_page=100"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA62QPQ+CMBCG/wrpCqEtOiijiYObu3Eo5QJN+pV+aIjhv1uCgu7kpve55J68d3uh6CSqUR+C9TXGzIqyE6GPTcmNwg6s8diLTrGHcNFXezxvd6UdsGQNSI9PsUMF0kxBOjQHbqRxKQGlbUXRWGzhOTM/rKJP+ppIBZTwrUy6Z5qDAh1+hH9wadhCmo28VyZc/kzvzy9Mr+YJZxPOZrx0JscDIWi8vwEYDk4FxwEAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"3c7806adc30a3c70862232625739e60e\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "57", "x-served-by": "a8d8e492d6966f0c23dee2eed64c678a", "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": "48A0C5F1:2E4E:4334473:53586757", "access-control-allow-credentials": "true", "last-modified": "Thu, 24 Apr 2014 00:44:08 GMT", "date": "Thu, 24 Apr 2014 01:22:31 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1398306151"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/issues/187/labels?per_page=100"}, "recorded_at": "2014-04-24T01:22:12"}], "recorded_with": "betamax/{version}"}

File tests/integration/test_issue.py

                 assert isinstance(event, github3.issues.event.IssueEvent)
                 assert event.issue is None
                 assert isinstance(event.actor, github3.users.User)
+
+    def test_iter_labels(self):
+        """Test the ability to iterate over issue labels."""
+        cassette_name = self.cassette_name('iter_labels')
+        with self.recorder.use_cassette(cassette_name):
+            issue = self.gh.issue('sigmavirus24', 'github3.py', 187)
+            assert issue is not None
+            for label in issue.iter_labels():
+                assert isinstance(label, github3.issues.label.Label)