aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/tests/utils/core.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-03-04 16:58:08 +0100
committerDavid Medina <davidmedina9@gmail.com>2012-03-04 17:18:06 +0100
commit14ef05b1ffef24fae97ae3e79567ab612a75ff11 (patch)
tree9397c561b8b963d9b65dbda1f496f01a0f2d3ab2 /pygithub3/tests/utils/core.py
parentWrap result getter into partial. It's cleaner (diff)
downloadpython-github3-14ef05b1ffef24fae97ae3e79567ab612a75ff11.tar.xz
python-github3-14ef05b1ffef24fae97ae3e79567ab612a75ff11.zip
Refactor result. Now it's a package
result.smart => Paginate iterator with 'page' behaviour. result.normal => Paginate iterator with 'next' behaviour.
Diffstat (limited to 'pygithub3/tests/utils/core.py')
-rw-r--r--pygithub3/tests/utils/core.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/pygithub3/tests/utils/core.py b/pygithub3/tests/utils/core.py
index 32170e4..677347a 100644
--- a/pygithub3/tests/utils/core.py
+++ b/pygithub3/tests/utils/core.py
@@ -13,6 +13,8 @@ request = DummyRequest()
json_content = [dict(name='dummy')]
+# To smart results
+
def mock_paginate_github_in_GET(request, page):
def header(page):
return {'link': '<https://d.com/d?page=%s>; rel="last"' % page}
@@ -33,3 +35,27 @@ def mock_no_paginate_github_in_GET(request, page):
response.headers = {}
response.content = [json_content * 3]
return response
+
+
+# To normal results
+class MockPaginate(object):
+
+ def __init__(self):
+ self.counter = 1
+
+ def content(self):
+ if self.counter >= 3:
+ return json_content
+ return json_content * 2
+
+ def header(self):
+ if self.counter >= 3:
+ return {}
+ return {'link': '<https://d.com/d?page=%s>; rel="next"' % self.counter}
+
+ def __call__(self, *args, **kwargs):
+ response = Mock()
+ response.headers = self.header()
+ response.content = self.content()
+ self.counter += 1
+ return response