-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
DeploymentStatus.py
83 lines (75 loc) · 3.84 KB
/
DeploymentStatus.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
# -*- coding: utf-8 -*-
############################ Copyrights and license ############################
# #
# Copyright 2020 Colby Gallup <colbygallup@gmail.com> #
# #
# 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/>. #
# #
################################################################################
import datetime
from . import Framework
class DeploymentStatus(Framework.TestCase):
def setUp(self):
super().setUp()
self.deployment = (
self.g.get_user().get_repo("PyGithub").get_deployment(242997115)
)
self.status = self.deployment.get_status(344110026)
def testAttributes(self):
self.assertEqual(self.status.id, 344110026)
created_at = datetime.datetime(2020, 6, 27, 18, 57, 35)
self.assertEqual(self.status.created_at, created_at)
self.assertEqual(self.status.creator.login, "colbygallup")
self.assertEqual(
self.status.deployment_url,
"https://api.github.com/repos/colbygallup/PyGithub/deployments/242997115",
)
self.assertEqual(self.status.description, "")
self.assertEqual(self.status.environment, "production")
self.assertEqual(
self.status.repository_url,
"https://api.github.com/repos/colbygallup/PyGithub",
)
self.assertEqual(self.status.state, "failure")
self.assertEqual(self.status.target_url, "")
self.assertEqual(self.status.updated_at, created_at)
self.assertEqual(
self.status.url,
"https://api.github.com/repos/colbygallup/PyGithub/deployments/242997115/statuses/344110026",
)
self.assertEqual(
self.status.node_id,
"MDE2OkRlcGxveW1lbnRTdGF0dXMzNDQxMTAwMjY=",
)
self.assertEqual(
repr(self.status),
'DeploymentStatus(url="https://api.github.com/repos/colbygallup/PyGithub/deployments/242997115/statuses/344110026", id=344110026)',
)
def testCreate(self):
newStatus = self.deployment.create_status("success")
self.assertEqual(newStatus.state, "success")
self.assertEqual(
newStatus.repository_url,
"https://api.github.com/repos/colbygallup/PyGithub",
)
def testGetStatuses(self):
statuses = self.deployment.get_statuses()
self.assertListKeyEqual(
statuses,
lambda s: s.id,
[346100235, 344427441, 344110026, 344109923, 344107728],
)