Skip to content

Commit cecd766

Browse files
Migrated remaining Struct tests to tests/{unit/integration}
1 parent 72fe5d3 commit cecd766

File tree

6 files changed

+41
-59
lines changed

6 files changed

+41
-59
lines changed
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"}, "method": "GET", "uri": "https://api.github.com/users/itsmemattchung/orgs?per_page=100"}, "response": {"body": {"string": "[]", "encoding": "utf-8"}, "headers": {"content-length": "2", "vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"ea774fb59d6af2dcf70015a9591dfbb2\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "57", "x-served-by": "8dd185e423974a7e13abbbe6e060031e", "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", "x-github-request-id": "97E45D32:14592:3D42A3D:56B5B20A", "access-control-allow-credentials": "true", "date": "Sat, 06 Feb 2016 08:42:50 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "strict-transport-security": "max-age=31536000; includeSubdomains; preload", "server": "GitHub.com", "x-ratelimit-limit": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1454750471"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/users/itsmemattchung/orgs?per_page=100"}, "recorded_at": "2016-02-06T08:42:51"}], "recorded_with": "betamax/0.5.0"}
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"}, "method": "GET", "uri": "https://api.github.com/users?per_page=10"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA63Z326bMBQG8HfhOiqi/xtp6lPsapoikjiJO4KRMclo1HefDT42ZhPa8fFVq9bfl680P9GkP25ZJY68ztbZWXyI81Zkq4zvs3WxyspLqUq56WSlv3tSqmnXeT5+sb07cnXqtl3L5E7UitXqbifOeZcX75dvD7rjKG3clGX6C7OahtuKMad72twvOKlzNXvg8QGH0/7cQVSVuOrsfOVCfe5CetX4Oa+P+AIduuVCnZi+RHr+l/mheatQU4bALTcfNnxvKlp9ySXbY+bYiB5zrfWOWy5ZI4aubtvuJG8UFzVqVhDURUIey5p/lugiHWx13gxCDRgCOsgu+pmFSo6JW95Ifil3vbkMku0Yv+hrim+bRXWZ6humn9Df9W/cXGGu2Kbcnw2gQ1m17GvlQe3Zoat/KX3MGLiPBHVPAOUXLIPy51CgbCweVFhAAQVNJFBQkg6Ua5xKjAEFRVhQkMODgmQaUH5HYHERlJJd4Kn5OPVMgaeHSE8PBE9+wbInfw7lycbiPYUFFE/QRPIEJek8uUaqJyjCeoIc3hMk03jyO+I9Xftdqcxd1tyeHiM5PRI4uQHLmtwxFKYxFW8pyFMo2SKSJNuRDhIUUh3ZHiwjG8MrssE0iNyK/zf01x957PMstrwDRk+RjJ4IjCYTliFNDqIoQS4e06yBwslVkUC5lnSkfCUVlWvCsnJBPCwXTUNrsoSAS79q6+396TkS1jMBln34ZVT2EAqUycRjmqQpkIYaEqKhIR2gsY6KZ2jBwhlCeDRDLA0Yu4CAhV3Kujn9tl5eIr28ELz4Bctk/DmUGhuLhxMWUOxAE4kPlKQT5BqpiKAI6whyeEqQTKPJ7yCAMp5YBe83FLGiCgopv2GZlD+HImVj8aTCAgopaCKRgpJ0pFwjlRQUYUlBDk8KkmlI+R0EUteyrxlr2bHT75jbfzS9Rt6pilfCrWo2ZBnX7DBK2DQbz+wfLRRrQR0JXNCUTl1YS6UXtGH9BWE8wiCeRuJsEYHjVvZ1KeElVvEWK/GNINFvWEboz6H82Vg8vbCAog6aSOCgJJ0110hlBkVYYZDD44JkGld+B5bUzz8sLL14RyEAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "W/\"fa2f89305cf250368e920c5f30d54b5c\"", "cache-control": "public, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "56", "x-served-by": "2811da37fbdda4367181b328b22b2499", "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:A4EA:6A9F36E:56B5B7D1", "access-control-allow-credentials": "true", "link": "<https://api.github.com/users?per_page=10&since=19>; rel=\"next\", <https://api.github.com/users{?since}>; rel=\"first\"", "date": "Sat, 06 Feb 2016 09:07:30 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": "60", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1454750471"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/users?per_page=10"}, "recorded_at": "2016-02-06T09:07:31"}], "recorded_with": "betamax/0.5.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"recorded_with": "betamax/0.5.1", "http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"Connection": "keep-alive", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "utf-8", "Content-Type": "application/json"}, "uri": "https://api.github.com/users?per_page=10", "method": "GET"}, "response": {"url": "https://api.github.com/users?per_page=10", "status": {"code": 200, "message": "OK"}, "body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA63Z326bMBQG8HfhOiqi/xtp6lPsapoikjiJO4KRMclo1HefDT42ZhPa8fFVq9bfl680P9GkP25ZJY68ztbZWXyI81Zkq4zvs3WxyspLqUq56WSlv3tSqmnXeT5+sb07cnXqtl3L5E7UitXqbifOeZcX75dvD7rjKG3clGX6C7OahtuKMad72twvOKlzNXvg8QGH0/7cQVSVuOrsfOVCfe5CetX4Oa+P+AIduuVCnZi+RHr+l/mheatQU4bALTcfNnxvKlp9ySXbY+bYiB5zrfWOWy5ZI4aubtvuJG8UFzVqVhDURUIey5p/lugiHWx13gxCDRgCOsgu+pmFSo6JW95Ifil3vbkMku0Yv+hrim+bRXWZ6humn9Df9W/cXGGu2Kbcnw2gQ1m17GvlQe3Zoat/KX3MGLiPBHVPAOUXLIPy51CgbCweVFhAAQVNJFBQkg6Ua5xKjAEFRVhQkMODgmQaUH5HYHERlJJd4Kn5OPVMgaeHSE8PBE9+wbInfw7lycbiPYUFFE/QRPIEJek8uUaqJyjCeoIc3hMk03jyO+I9Xftdqcxd1tyeHiM5PRI4uQHLmtwxFKYxFW8pyFMo2SKSJNuRDhIUUh3ZHiwjG8MrssE0iNyK/zf01x957PMstrwDRk+RjJ4IjCYTliFNDqIoQS4e06yBwslVkUC5lnSkfCUVlWvCsnJBPCwXTUNrsoSAS79q6+396TkS1jMBln34ZVT2EAqUycRjmqQpkIYaEqKhIR2gsY6KZ2jBwhlCeDRDLA0Yu4CAhV3Kujn9tl5eIr28ELz4Bctk/DmUGhuLhxMWUOxAE4kPlKQT5BqpiKAI6whyeEqQTKPJ7yCAMp5YBe83FLGiCgopv2GZlD+HImVj8aTCAgopaCKRgpJ0pFwjlRQUYUlBDk8KkmlI+R0EUteyrxlr2bHT75jbfzS9Rt6pilfCrWo2ZBnX7DBK2DQbz+wfLRRrQR0JXNCUTl1YS6UXtGH9BWE8wiCeRuJsEYHjVvZ1KeElVvEWK/GNINFvWEboz6H82Vg8vbCAog6aSOCgJJ0110hlBkVYYZDD44JkGld+B5bUzz8sLL14RyEAAA==", "string": ""}, "headers": {"X-Content-Type-Options": "nosniff", "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", "X-RateLimit-Remaining": "55", "Cache-Control": "public, max-age=60, s-maxage=60", "Server": "GitHub.com", "Vary": "Accept", "X-Frame-Options": "deny", "Transfer-Encoding": "chunked", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Link": "<https://api.github.com/users?per_page=10&since=19>; rel=\"next\", <https://api.github.com/users{?since}>; rel=\"first\"", "Content-Type": "application/json; charset=utf-8", "X-RateLimit-Reset": "1454750471", "X-GitHub-Request-Id": "97E45D32:A4EA:6AA0B38:56B5B7F7", "Status": "200 OK", "Access-Control-Allow-Credentials": "true", "Content-Security-Policy": "default-src 'none'", "ETag": "W/\"fa2f89305cf250368e920c5f30d54b5c\"", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Access-Control-Allow-Origin": "*", "Content-Encoding": "gzip", "X-RateLimit-Limit": "60", "X-XSS-Protection": "1; mode=block", "Date": "Sat, 06 Feb 2016 09:08:07 GMT", "X-Served-By": "a6882e5cd2513376cb9481dbcd83f3a2"}}, "recorded_at": "2016-02-06T09:08:08"}]}

tests/integration/test_structs.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class TestGitHubIterator(IntegrationHelper):
88
def test_resets_etag(self):
9+
"""Show that etag resets to None after refreshing the object."""
910
cassette_name = self.cassette_name('resets_etag')
1011
with self.recorder.use_cassette(cassette_name):
1112
users_iter = self.gh.all_users(number=10)
@@ -15,10 +16,35 @@ def test_resets_etag(self):
1516
users_iter.refresh()
1617
assert users_iter.etag is None
1718

19+
def test_catch_etags(self):
20+
"""Show that etag gets during iteration."""
21+
cassette_name = self.cassette_name('catch_etags')
22+
with self.recorder.use_cassette(cassette_name):
23+
users_iter = self.gh.all_users(number=10)
24+
assert users_iter.etag is None
25+
next(users_iter) # Make the request
26+
assert users_iter.etag is not None
27+
28+
def test_catch_None(self):
29+
"""Show that StopIteration is raised when response is empty."""
30+
cassette_name = self.cassette_name('catch_None')
31+
with self.recorder.use_cassette(cassette_name):
32+
orgs_iter = self.gh.organizations_with('itsmemattchung')
33+
with pytest.raises(StopIteration):
34+
next(orgs_iter)
35+
1836
def test_count_reaches_0(self):
37+
"""Tests __iter__ and while loop reaches 0."""
1938
cassette_name = self.cassette_name('count_reaches_0')
2039
with self.recorder.use_cassette(cassette_name):
2140
users_iter = self.gh.all_users(number=1)
2241
assert isinstance(next(users_iter), github3.users.User)
2342
with pytest.raises(StopIteration):
2443
next(users_iter)
44+
45+
def test_next(self):
46+
"""Test method returns next value."""
47+
cassette_name = self.cassette_name('next')
48+
with self.recorder.use_cassette(cassette_name):
49+
users_iter = self.gh.all_users(number=10)
50+
assert isinstance(next(users_iter), github3.users.User)

tests/test_structs.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/unit/test_structs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ def _klass(*args):
2020
session=self.session)
2121
return instance
2222

23+
def test_refresh(self):
24+
"""Show that __iter__ is called when refreshing."""
25+
with mock.patch.object(GitHubIterator, '__iter__') as i:
26+
self.instance.refresh()
27+
assert i.called is True
28+
29+
def test_refresh_conditional(self):
30+
"""Show that __iter__ is called when refreshing."""
31+
with mock.patch.object(GitHubIterator, '__iter__') as i:
32+
self.instance.refresh(True)
33+
assert i.called is True
34+
2335
def test_sets_per_page_to_100(self):
2436
"""Test that the Iterator defaults the per_page parameter to 100"""
2537
self.session.get.return_value = mock.Mock(status_code=200,

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