aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/tests/utils/core.py
blob: 8d18732d621c8ad18bb65a0cf0b5ef1b01fb0bed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from .base import Mock, DummyRequest

request = DummyRequest()
# Working without json but name it json-related to not confuse
json_content = [dict(name='dummy')]


def mock_paginate_github_in_GET(request, page):
    def header(page):
        return {'link': '<https://d.com/d?page=%s>; rel="last"' % page}

    def content(page):
        if page >= 3:
            return json_content
        return json_content * 2

    response = Mock()
    response.headers = header(3)
    response.content = content(page)
    return response


def mock_no_paginate_github_in_GET(request, page):
    response = Mock()
    response.headers = {}
    response.content = [json_content * 3]
    return response