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

Skip to content
8000

Commit 435bea3

Browse files
Added ability to retrieve status of multiple imported issues
Created unit and integration test for imported_issues Closes: #497
1 parent 51cfbf8 commit 435bea3

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
@@ -1279,6 +1279,32 @@ def imported_issue(self, imported_issue_id):
12791279
json = self._json(data, 200)
12801280
return self._instance_or_null(ImportedIssue, json)
12811281

1282+
@requires_auth
1283+
def imported_issues(self, number=-1, since=None, etag=None):
1284+
"""Retrieve imported issues
1285+
1286+
:param int number: (optional), number of imported issues to return.
1287+
Default: -1 returns all branches
1288+
:param since: (optional), Only commits after this date will
1289+
be returned. This can be a `datetime` or an `ISO8601` formatted
1290+
date string.
1291+
:param str etag: (optional), ETag from a previous request to the same
1292+
endpoint
1293+
:returns: generator of :class:`ImportedIssue <github3.repos.
1294+
issue_import.ImportedIssue>`
1295+
"""
1296+
1297+
data = {
1298+
'since': since
1299+
}
1300+
1301+
self._remove_none(data)
1302+
url = self._build_url('import/issues', base_url=self._api)
1303+
1304+
return self._iter(int(number), url, ImportedIssue, etag=etag,
1305+
params=data,
1306+
headers=ImportedIssue.IMPORT_CUSTOM_HEADERS)
1307+
12821308
@requires_auth
12831309
def import_issue(self, title, body, created_at, assignee=None,
12841310
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/github3py/test_rename1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AZgE6nBfVhQCWznE41p4RMt8GZiKulDX0INnQqHI1QI1SHrgFsXD9mWz/+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
@@ -1144,6 +1144,19 @@ def test_hooks(self):
11441144
headers={}
11451145
)
11461146

1147+
def test_imported_issues(self):
1148+
"""Verify the request for retreiving imported issues."""
1149+
i = self.instance.imported_issues(since='2015-03-15')
1150+
self.get_next(i)
1151+
1152+
self.session.get.assert_called_once_with(
1153+
url_for('import/issues'),
1154+
params={'per_page': 100, 'since': '2015-03-15'},
1155+
headers={
1156+
'Accept': 'application/vnd.github.golden-comet-preview+json'
1157+
}
1158+
)
1159+
11471160
def test_issue_events(self):
11481161
"""Test the ability to iterate over a repository's issue events."""
11491162
i = self.instance.issue_events()
@@ -1473,6 +1486,12 @@ def test_import_issue(self):
14731486
body='Foobar body',
14741487
created_at='2014-03-16T17:15:42Z')
14751488

1489+
def test_imported_issues(self):
1490+
"""
1491+
Show that a user must be authenticated to retrieve imported issues.
1492+
"""
1493+
self.assert_requires_auth(self.instance.imported_issues)
1494+
14761495
def test_imported_issue(self):
14771496
"""
14781497
Show that a user must be authenticated to retrieve an imported issue.

0 commit comments

Comments
 (0)
0