Skip to content

Commit d3552f7

Browse files
committed
Merge pull request sigmavirus24#559 from itsmemattchung/issue/497
Added ability to retrieve status of multiple imported issues
2 parents a7b0b88 + 8b9b37d commit d3552f7

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

github3/repos/repo.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ def commits(self, sha=None, path=None, author=None, number=-1, etag=None,
534534
:param str etag: (optional), ETag from a previous request to the same
535535
endpoint
536536
:param since: (optional), Only commits after this date will
537-
be returned. This can be a `datetime` or an `ISO8601` formatted
537+
be returned. This can be a ``datetime`` or an ``ISO8601`` formatted
538538
date string.
539539
:type since: datetime or string
540540
:param until: (optional), Only commits before this date will
541-
be returned. This can be a `datetime` or an `ISO8601` formatted
541+
be returned. This can be a ``datetime`` or an ``ISO8601`` formatted
542542
date string.
543543
:type until: datetime or string
544544
@@ -1281,6 +1281,35 @@ 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 the collection of imported issues via the API.
1287+
1288+
See also: https://gist.github.com/jonmagic/5282384165e0f86ef105
1289+
1290+
:param int number: (optional), number of imported issues to return.
1291+
Default: -1 returns all branches
1292+
:param since: (optional), Only imported issues after this date will
1293+
be returned. This can be a ``datetime`` instance, ISO8601
1294+
formatted date string, or a string formatted like so:
1295+
``2016-02-04`` i.e. ``%Y-%m-%d``
1296+
:param str etag: (optional), ETag from a previous request to the same
1297+
endpoint
1298+
:returns: generator of :class:`ImportedIssue <github3.repos.
1299+
issue_import.ImportedIssue>`
1300+
"""
1301+
1302+
data = {
1303+
'since': timestamp_parameter(since)
1304+
}
1305+
1306+
self._remove_none(data)
1307+
url = self._build_url('import/issues', base_url=self._api)
1308+
1309+
return self._iter(int(number), url, ImportedIssue, etag=etag,
1310+
params=data,
1311+
headers=ImportedIssue.IMPORT_CUSTOM_HEADERS)
1312+
12841313
@requires_auth
12851314
def import_issue(self, title, body, created_at, assignee=None,
12861315
milestone=None, closed=None, labels=None, comments=None):
@@ -1397,7 +1426,7 @@ def issues(self, milestone=None, state=None, assignee=None, mentioned=None,
13971426
('created', 'updated', 'comments', 'created')
13981427
:param str direction: (optional), accepted values: ('asc', 'desc')
13991428
:param since: (optional), Only issues after this date will
1400-
be returned. This can be a `datetime` or an `ISO8601` formatted
1429+
be returned. This can be a ``datetime`` or an ``ISO8601`` formatted
14011430
date string, e.g., 2012-05-20T23:10:27Z
14021431
:type since: datetime or string
14031432
:param int number: (optional), Number of issues to return.
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"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA+2Yz46jOBDG34XrZONOMpmdQVrNvMFc9rSXyAEHrAaMbJMojfrd5yubf0ErkrSvLbVaBFw/PpddpqraSKZRvNt93Wxevv1YRRUvRRRHVhh70IJ+baJVdGqK4tA9yqTNm+OuvrLZIHWphI7iNipUJitAhpEg0Fs2f3/fbvbfVhE/c8v1odEFRuXW1iZmzN80a2/VGKETVVlR2XWiStawzvrn+Z8deJnuIASOcGMGq2UH8tagGTbVk9uymAnwj9346ciTKgp1gf1c7+Ir2GBG7nMIWWUfQcCsZcrmAg7DNN5p8tLYJ+U4kxYTw7rKlCAGS6BF+pykzgiCaLHfW6ZFrRytOZpEy9pKVT0p7cYUKKUzXsk3/gEUTA0IJOpJEc4EpuKMHfekrbdpWa3lmSdXcocWiZBnePcjvJkxc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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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy