-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
GithubApp.py
138 lines (131 loc) · 5.79 KB
/
GithubApp.py
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2020 Raju Subramanian <coder@mahesh.net> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
# #
# PyGithub is free software: you can redistribute it and/or modify it under #
# the terms of the GNU Lesser General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
# details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
from datetime import datetime
from . import Framework
class GithubApp(Framework.TestCase):
def setUp(self):
super().setUp()
self.app_slug = "github-actions"
def testGetPublicApp(self):
app = self.g.get_app(slug=self.app_slug)
self.assertEqual(app.created_at, datetime(2018, 7, 30, 9, 30, 17))
self.assertEqual(
app.description, "Automate your workflow from idea to production"
)
self.assertListEqual(
app.events,
[
"check_run",
"check_suite",
"create",
"delete",
"deployment",
"deployment_status",
"fork",
"gollum",
"issues",
"issue_comment",
"label",
"milestone",
"page_build",
"project",
"project_card",
"project_column",
"public",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"push",
"registry_package",
"release",
"repository",
"repository_dispatch",
"status",
"watch",
"workflow_dispatch",
"workflow_run",
],
)
self.assertEqual(app.external_url, "https://help.github.com/en/actions")
self.assertEqual(app.html_url, "https://github.com/apps/github-actions")
self.assertEqual(app.id, 15368)
self.assertEqual(app.name, "GitHub Actions")
self.assertEqual(app.owner.login, "github")
self.assertDictEqual(
app.permissions,
{
"actions": "write",
"checks": "write",
"contents": "write",
"deployments": "write",
"issues": "write",
"metadata": "read",
"packages": "write",
"pages": "write",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "write",
"security_events": "write",
"statuses": "write",
"vulnerability_alerts": "read",
},
)
self.assertEqual(app.slug, "github-actions")
self.assertEqual(app.updated_at, datetime(2019, 12, 10, 19, 4, 12))
self.assertEqual(app.url, "/apps/github-actions")
def testGetAuthenticatedApp(self):
# For this to work correctly in record mode, this test must be run with --auth_with_jwt
app = self.g.get_app()
# At this point the GithubApp object is not complete.
# The url should change when the object is completed - after pulling it down
# from the github API
self.assertEqual(app.url, "/app")
self.assertEqual(app.created_at, datetime(2020, 8, 1, 17, 23, 46))
self.assertEqual(app.description, "Sample App to test PyGithub")
self.assertListEqual(
app.events,
["check_run", "check_suite", "label", "member", "public"],
)
self.assertEqual(app.external_url, "https://pygithub.readthedocs.io")
self.assertEqual(app.html_url, "https://github.com/apps/pygithubtest")
self.assertEqual(app.id, 75269)
self.assertEqual(app.name, "PyGithubTest")
self.assertEqual(app.owner.login, "wrecker")
self.assertDictEqual(
app.permissions,
{
"actions": "write",
"checks": "write",
"keys": "read",
"members": "read",
"metadata": "read",
"packages": "read",
"pages": "read",
"repository_hooks": "write",
"vulnerability_alerts": "read",
"workflows": "write",
},
)
self.assertEqual(app.slug, "pygithubtest")
self.assertEqual(app.updated_at, datetime(2020, 8, 1, 17, 44, 31))
self.assertEqual(app.url, "/apps/pygithubtest")