forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_checks.py
More file actions
98 lines (71 loc) · 2.71 KB
/
Copy pathtest_checks.py
File metadata and controls
98 lines (71 loc) · 2.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""Unit tests around github3's Checks classes."""
import pytest
from json import dumps
import github3
from github3.checks import CheckRun, CheckSuite
from github3.exceptions import GitHubException
from .helper import (
UnitAppInstallHelper,
UnitRequiresAuthenticationHelper,
UnitHelper,
UnitIteratorHelper,
create_url_helper,
create_example_data_helper,
)
url_for = create_url_helper("https://api.github.com/repos/github/hello-world")
check_run_example_data = create_example_data_helper("check_run_example")
check_suite_example_data = create_example_data_helper("check_suite_example")
class TestCheckRun(UnitAppInstallHelper):
described_class = CheckRun
example_data = check_run_example_data()
def test_update(self):
"""Show that a check run can be updated"""
data = {"name": "newname"}
self.instance.update(**data)
self.session.patch.assert_called_once_with(
url_for("check-runs/4"),
dumps(data),
headers=CheckRun.CUSTOM_HEADERS,
)
def test_check_run_types(self):
"""Check that we get the right types"""
assert isinstance(self.instance.app, github3.checks.CheckApp)
assert isinstance(
self.instance.original_pull_requests[0],
github3.checks.CheckPullRequest,
)
class TestCheckRunRequiresAuth(UnitRequiresAuthenticationHelper):
described_class = CheckRun
example_data = check_run_example_data()
def test_update_requires_auth(self):
"""Show updating a run requires auth"""
with pytest.raises(GitHubException):
self.instance.update(name="newname")
class TestCheckSuite(UnitHelper):
described_class = CheckSuite
example_data = check_suite_example_data()
def test_rerequest(self):
"""Show that a check suite can be rerequested"""
self.instance.rerequest()
self.session.post.assert_called_once_with(
url_for("check-suites/5/rerequest"),
None,
headers=CheckSuite.CUSTOM_HEADERS,
)
def test_check_suite_types(self):
"""Check that we get the right types"""
assert isinstance(self.instance.app, github3.checks.CheckApp)
assert isinstance(
self.instance.repository, github3.repos.ShortRepository
)
class TestCheckSuiteIterator(UnitIteratorHelper):
described_class = CheckSuite
example_data = check_suite_example_data()
def test_check_runs(self):
i = self.instance.check_runs()
self.get_next(i)
self.session.get.assert_called_once_with(
url_for("check-suites/5/check-runs"),
params={"per_page": 100},
headers=CheckSuite.CUSTOM_HEADERS,
)