Commits

Ian Cordasco committed 3fd345a

Add etag parameter to Repository#milestone

- Add integration test for retrieving a milestone

Comments (0)

Files changed (3)

github3/issues/milestone.py

         """
         return self._boolean(self._delete(self._api), 204, 404)
 
-    def iter_labels(self, number=-1):
+    def iter_labels(self, number=-1, etag=None):
         """Iterate over the labels for every issue associated with this
         milestone.
 
+        .. versionchanged:: 0.9
+
+            Add etag parameter.
+
         :param int number: (optional), number of labels to return. Default: -1
             returns all available labels.
+        :param str etag: (optional), ETag header from a previous request to
+            this endpoint
         :returns: generator of :class:`Label <Label>`\ s
         """
         url = self._build_url('labels', base_url=self._api)
-        return self._iter(int(number), url, Label)
+        return self._iter(int(number), url, Label, etag=etag)
 
     @requires_auth
     def update(self, title=None, state=None, description=None, due_on=None):

tests/cassettes/Repository_milestone.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": "H4sIAAAAAAAAA62Yy5KrNhCGX8XFNh7LGF/ZnGSVZHcWJ5tsXAKEUQ0gShJ2eah59/xCGINP4ssoG5eN1Z9+tbpFtxqPJ14YbPz5xvenXkkL5oXegeusjoJZdfamXlrn+b77Q/FDQY9c1mqxJKNR4lQy6YWNl4sDL8EYDgXFTLNYzrfBfOrRI9VU7muZY1ymdaVCQuxDNbPUWjEZi1KzUs9iUZCaWONvQB1kBzBML/aX22C1Tra7dLdYsfVu4W+2EWN+sgtonG5gcDNRxbtJLBkzKXKjNtNFfqPP6mpNbganIs/FCZTbFT2aiPSWxs0thZeHL1Jg2RChMwbHYkmfxlFc6ddFtVYNdlfpPU8MR2G3JEteFtbZQZYJjs+GSFaJFlhHKpa80lyUrwscWYMm5IGW/IN+jQZrBYiR9rqU1grW7IhAfd3cmjWkkv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Q3A6EwAA", "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": "\"1540b94b7f309441bf1658760d4218c8\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "57", "x-served-by": "a1d8c69b807c8e21f06cad9da377d1b0", "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:439F:5C7BD84:5359B3F1", "access-control-allow-credentials": "true", "last-modified": "Thu, 24 Apr 2014 01:23:29 GMT", "date": "Fri, 25 Apr 2014 01:01:37 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": "1398391232"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2014-04-25T01:01:18"}, {"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/milestones/7"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA61Uy46jMBD8F58zmGdCuMxPzF72ggx0iCVjI7vNKIPy79OG7GjCSisx2htqqsrV5W7PzFvFKnZFHF3FuRhl1Eu8+iZqzcAtjMZxJ/tBTNJ6l+Z8/ZtF440PUoFDo8HxEzswJRpQrv5PgnyVI13Zsao4pXlyPDDthwYsq04HhhIVkPU4OkcxwTpwrZUjSqOpSoXWgkBD4Jkp08tQ/d7JQznN4zKLD0xMAoXdul+K7hGJd2BboxE0Lul4vpJfSaq3D4HglrVJXmbFsSvPl3NawPGcJqeyAUi6cybaS0jrnzGFk55zJ8YVB7Xx9+2qNq1djFLmnVS2HT1f8N8H8S8mHbl+S93/UIWYMzd4BQqWWrqHoKTD/aYW1kzD57CWXdBxdDEWut3GHjyy9a7J0bzM+CLom68B2m/wiU1qxvZCyw8RxnG/GrEdiSzrt7vDhUVsmGhQ99NX2sxHKyfR3kI0FlqQE4X9Q8kNnxTxNobd/UVDEaKXCLXohrCjF6Ec3CnAEXQtnfPgWJXQNivjyMGfSr5MAAaRgCSRZd0JIZBqaZzkL3H6kpRvcVrlMT0gvwnjx26LyQj2lhRVnlVFFjCdhzo8Idordf8ENrcoqCAFAAA=", "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": "\"f5989776e365a3f9a2c20b04432aee01\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "56", "x-served-by": "62a1303ae95931e56e387e87d354bb24", "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:439F:5C7BDAB:5359B3F1", "access-control-allow-credentials": "true", "last-modified": "Fri, 25 Apr 2014 00:42:12 GMT", "date": "Fri, 25 Apr 2014 01:01:37 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": "1398391232"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/milestones/7"}, "recorded_at": "2014-04-25T01:01:18"}], "recorded_with": "betamax/{version}"}

tests/integration/test_repos_repo.py

             for release in repository.iter_releases():
                 assert isinstance(release, github3.repos.release.Release)
 
+    def test_milestone(self):
+        """
+        Test the ability to retrieve a specific milestone on a repository.
+        """
+        cassette_name = self.cassette_name('milestone')
+        with self.recorder.use_cassette(cassette_name):
+            repository = self.gh.repository('sigmavirus24', 'github3.py')
+            assert repository is not None
+            milestone = repository.milestone(7)
+        assert isinstance(milestone, github3.issues.milestone.Milestone)
+
     def test_release(self):
         """Test the ability to retrieve a single release."""
         cassette_name = self.cassette_name('release')