8000 Added ability to retrieve status of multiple imported issues · pythonthings/github3.py@723bd8a · GitHub
[go: up one dir, main page]

Skip to content

Commit 723bd8a

Browse files
Added ability to retrieve status of multiple imported issues
Created unit and integration test for imported_issues Closes: sigmavirus24#497
1 parent a7b0b88 commit 723bd8a

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

github3/repos/repo.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,32 @@ def imported_issue(self, imported_issue_id):
12811281
json = self._json(data, 200)
12821282
return self._instance_or_null(ImportedIssue, json)
12831283

1284+
@requires_auth
1285+
def imported_issues(self, number=-1, since=None, etag=None):
1286+
"""Retrieve imported issues
1287+
1288+
:param int number: (optional), number of imported issues to return.
1289+
Default: -1 returns all branches
1290+
:param since: (op 8000 tional), Only commits after this date will
1291+
be returned. This can be a `datetime` or an `ISO8601` formatted
1292+
date string.
1293+
:param str etag: (optional), ETag from a previous request to the same
1294+
endpoint
1295+
:returns: generator of :class:`ImportedIssue <github3.repos.
1296+
issue_import.ImportedIssue>`
1297+
"""
1298+
1299+
data = {
1300+
'since': since
1301+
}
1302+
1303+
self._remove_none(data)
1304+
url = self._build_url('import/issues', base_url=self._api)
1305+
1306+
return self._iter(int(number), url, ImportedIssue, etag=etag,
1307+
params=data,
1308+
headers=ImportedIssue.IMPORT_CUSTOM_HEADERS)
1309+
12841310
@requires_auth
12851311
def import_issue(self, title, body, created_at, assignee=None,
12861312
milestone=None, closed=None, labels=None, comments=None):
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/github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FREYpgtzjAZgE6nBfVhQCWznE41p4RMt8GZiKulDX0INnQqHI1QI1SHrgFsXD9mWz/+vlK/7+3ezj/fd4t/0PY5o6XRiz39CYujH5HQwO0m5D4wpdhP8r4m9KEGoLAG1MPtr9Gq1ifzlvb3RWSYGdOQugh994nn/X7lpCZ65KUSPFiOIKoUI13xuuX25yhUQ1FTyNmxdukcziqzze6vOLHpBzc/BxHMVWN1Qi4s54TExuXuSrnA4iHWYoAn0hN76olFqrrqnjtapaVN27ekFbaoZQAUdqJ8+jGE969e5hKk68KezB59TYRyU3Fv0l7AqhS8yAGg3UbeoKYD8X2jG9ZDpb/DXq4mlT4bNH1TXwPntUY/dxuZv32aO67aAiRblpcCEsH+9RVcJecAhMDqlpQdGdKNv3Pw/iJ5WbFgAA", "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/\"13a47a4d1a5c47a7a39be7630d80c17c\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4991", "x-served-by": "a6882e5cd2513376cb9481dbcd83f3a2", "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:14F4C:367C294:56ACB87A", "access-control-allow-credentials": "true", "last-modified": "Sat, 04 Apr 2015 15:58:51 GMT", "date": "Sat, 30 Jan 2016 13:19:54 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": "1454161385"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/github3py/test_rename1"}, "recorded_at": "2016-01-30T13:19:55"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.golden-comet-preview+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/github3py/test_rename1/import/issues?per_page=100"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA9WRuw7CMAxF/8UrpbHb8ki+gw2hKrQRRKI0StwBIf6d0AgYQQgG1ivr2NdnfQbbgiqlXEjMILDmIYAC27nes2khg8EfYrBndkEJoZ3Nd5b3wzZv+k544/ogUlC6k2ATuPbmqDtDIkGEDWEwQaQdEZjiOsX1l/CRO95iufenz6ER03ijY/Nac6xdIM2nSFOqViTVjFRBE0SFeHuMa98bHJt+ftP9gQSXLOmqECXNf6sr7fhXXcsVVaqQivCFrsfg0+uXdBVw2VwBSH+sCl8DAAA=", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "x-github-media-type": "github.golden-comet-preview; 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/\"48dbaef3f5b20510df98e3f2cbe50005\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4990", "x-served-by": "a7f8a126c9ed3f1c4715a34c0ddc7290", "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:14F4C:367C2C9:56ACB87A", "access-control-allow-credentials": "true", "date": "Sat, 30 Jan 2016 13:19:54 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": "1454161385"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/github3py/test_rename1/import/issues?per_page=100"}, "recorded_at": "2016-01-30T13:19:55"}], "recorded_with": "betamax/0.5.0"}

tests/integration/test_repos_repo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,19 @@ def test_imported_issue(self):
612612
assert isinstance(imported_issue,
613613
github3.repos.issue_import.ImportedIssue)
614614

615+
def test_imported_issues(self):
616+
"""Test the ability to retrieve imported issues."""
617+
self.token_login()
618+
cassette_name = self.cassette_name('imported_issues')
619+
with self.recorder.use_cassette(cassette_name):
620+
repository = self.gh.repository('github3py', 'test_rename1')
621+
imported_issues = list(repository.imported_issues())
622+
623+
assert len(imported_issues) > 0
624+
for imported_issue in imported_issues:
625+
assert isinstance(imported_issue,
626+
github3.repos.issue_import.ImportedIssue)
627+
615628
def test_import_issue(self):
616629
"""Test the ability to import an issue."""
617630
self.token_login()

tests/unit/test_repos_repo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,19 @@ def test_hooks(self):
11751175
headers={}
11761176
)
11771177

1178+
def test_imported_issues(self):
1179+
"""Verify the request for retreiving imported issues."""
1180+
i = self.instance.imported_issues(since='2015-03-15')
1181+
self.get_next(i)
1182+
1183+
self.session.get.assert_called_once_with(
1184+
url_for('import/issues'),
1185+
params={'per_page': 100, 'since': '2015-03-15'},
1186+
headers={
1187+
'Accept': 'application/vnd.github.golden-comet-preview+json'
1188+
}
1189+
)
1190+
11781191
def test_issue_events(self):
11791192
"""Test the ability to iterate over a repository's issue events."""
11801193
i = self.instance.issue_events()
@@ -1504,6 +1517,12 @@ def test_import_issue(self):
15041517
body='Foobar body',
15051518
created_at='2014-03-16T17:15:42Z')
15061519

1520+
def test_imported_issues(self):
1521+
"""
1522+
Show that a user must be authenticated to retrieve imported issues.
1523+
"""
1524+
self.assert_requires_auth(self.instance.imported_issues)
1525+
15071526
def test_imported_issue(self):
15081527
"""
15091528
Show that a user must be authenticated to retrieve an imported issue.

0 commit comments

Comments
 (0)
0