From 0384e2fd13b400c0e98e42c36ba29ace233d6dd3 Mon Sep 17 00:00:00 2001 From: alson Date: Tue, 13 Jun 2023 21:07:11 +0200 Subject: [PATCH] Add support for environments (#2223) --- github/Environment.py | 123 ++++++++++++ github/EnvironmentDeploymentBranchPolicy.py | 75 ++++++++ github/EnvironmentProtectionRule.py | 81 ++++++++ github/EnvironmentProtectionRuleReviewer.py | 80 ++++++++ github/Repository.py | 94 +++++++++ github/Repository.pyi | 26 +++ tests/Environment.py | 179 ++++++++++++++++++ tests/ReplayData/Environment.setUp.txt | 33 ++++ .../Environment.testCreateEnvironment.txt | 11 ++ .../Environment.testDeleteEnvironment.txt | 22 +++ .../Environment.testGetEnvironments.txt | 22 +++ .../ReplayData/Environment.testReviewers.txt | 11 ++ .../Environment.testUpdateEnvironment.txt | 11 ++ 13 files changed, 768 insertions(+) create mode 100644 github/Environment.py create mode 100644 github/EnvironmentDeploymentBranchPolicy.py create mode 100644 github/EnvironmentProtectionRule.py create mode 100644 github/EnvironmentProtectionRuleReviewer.py create mode 100644 tests/Environment.py create mode 100644 tests/ReplayData/Environment.setUp.txt create mode 100644 tests/ReplayData/Environment.testCreateEnvironment.txt create mode 100644 tests/ReplayData/Environment.testDeleteEnvironment.txt create mode 100644 tests/ReplayData/Environment.testGetEnvironments.txt create mode 100644 tests/ReplayData/Environment.testReviewers.txt create mode 100644 tests/ReplayData/Environment.testUpdateEnvironment.txt diff --git a/github/Environment.py b/github/Environment.py new file mode 100644 index 00000000..fb8a2730 --- /dev/null +++ b/github/Environment.py @@ -0,0 +1,123 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Alson van der Meulen # +# # +# 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 . # +# # +################################################################################ + +import datetime +from typing import List + +import github.EnvironmentDeploymentBranchPolicy +import github.EnvironmentProtectionRule +import github.GithubObject + + +class Environment(github.GithubObject.CompletableGithubObject): + """ + This class represents Environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments + """ + + def __repr__(self): + return self.get__repr__({"name": self._name.value}) + + @property + def created_at(self) -> datetime.datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def protection_rules( + self, + ) -> List[github.EnvironmentProtectionRule.EnvironmentProtectionRule]: + self._completeIfNotSet(self._protection_rules) + return self._protection_rules.value + + @property + def updated_at(self) -> datetime.datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def deployment_branch_policy( + self, + ) -> github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicy: + self._completeIfNotSet(self._deployment_branch_policy) + return self._deployment_branch_policy.value + + def _initAttributes(self): + self._created_at = github.GithubObject.NotSet + self._html_url = github.GithubObject.NotSet + self._id = github.GithubObject.NotSet + self._name = github.GithubObject.NotSet + self._node_id = github.GithubObject.NotSet + self._protection_rules = github.GithubObject.NotSet + self._updated_at = github.GithubObject.NotSet + self._url = github.GithubObject.NotSet + self._deployment_branch_policy = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "protection_rules" in attributes: # pragma no branch + self._protection_rules = self._makeListOfClassesAttribute( + github.EnvironmentProtectionRule.EnvironmentProtectionRule, + attributes["protection_rules"], + ) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "deployment_branch_policy" in attributes: # pragma no branch + self._deployment_branch_policy = self._makeClassAttribute( + github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicy, + attributes["deployment_branch_policy"], + ) diff --git a/github/EnvironmentDeploymentBranchPolicy.py b/github/EnvironmentDeploymentBranchPolicy.py new file mode 100644 index 00000000..51c1c0e8 --- /dev/null +++ b/github/EnvironmentDeploymentBranchPolicy.py @@ -0,0 +1,75 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Alson van der Meulen # +# # +# 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 . # +# # +################################################################################ + +import github.EnvironmentProtectionRuleReviewer +import github.GithubObject + + +class EnvironmentDeploymentBranchPolicy(github.GithubObject.NonCompletableGithubObject): + """ + This class represents a deployment branch policy for an environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments + """ + + def __repr__(self): + return self.get__repr__({}) + + @property + def protected_branches(self) -> bool: + return self._protected_branches.value + + @property + def custom_branch_policies(self) -> bool: + return self._custom_branch_policies.value + + def _initAttributes(self): + self._protected_branches = github.GithubObject.NotSet + self._custom_branch_policies = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "protected_branches" in attributes: # pragma no branch + self._protected_branches = self._makeBoolAttribute( + attributes["protected_branches"] + ) + if "custom_branch_policies" in attributes: # pragma no branch + self._custom_branch_policies = self._makeBoolAttribute( + attributes["custom_branch_policies"] + ) + + +class EnvironmentDeploymentBranchPolicyParams: + """ + This class presents the deployment branch policy parameters as can be configured for an Environment. + """ + + def __init__( + self, protected_branches: bool = False, custom_branch_policies: bool = False + ): + assert isinstance(protected_branches, bool) + assert isinstance(custom_branch_policies, bool) + self.protected_branches = protected_branches + self.custom_branch_policies = custom_branch_policies + + def _asdict(self) -> dict: + return { + "protected_branches": self.protected_branches, + "custom_branch_policies": self.custom_branch_policies, + } diff --git a/github/EnvironmentProtectionRule.py b/github/EnvironmentProtectionRule.py new file mode 100644 index 00000000..6f1ee5e6 --- /dev/null +++ b/github/EnvironmentProtectionRule.py @@ -0,0 +1,81 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Alson van der Meulen # +# # +# 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 . # +# # +################################################################################ + +from typing import List + +import github.EnvironmentProtectionRuleReviewer +import github.GithubObject + + +class EnvironmentProtectionRule(github.GithubObject.NonCompletableGithubObject): + """ + This class represents a protection rule for an environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments + """ + + def __repr__(self): + return self.get__repr__({"id": self._id.value}) + + @property + def id(self) -> int: + return self._id.value + + @property + def node_id(self) -> str: + return self._node_id.value + + @property + def type(self) -> str: + return self._type.value + + @property + def reviewers( + self, + ) -> List[ + github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer + ]: + return self._reviewers.value + + @property + def wait_timer(self) -> int: + return self._wait_timer.value + + def _initAttributes(self): + self._id = github.GithubObject.NotSet + self._node_id = github.GithubObject.NotSet + self._type = github.GithubObject.NotSet + self._reviewers = github.GithubObject.NotSet + self._wait_timer = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) + if "reviewers" in attributes: # pragma no branch + self._reviewers = self._makeListOfClassesAttribute( + github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer, + attributes["reviewers"], + ) + if "wait_timer" in attributes: # pragma no branch + self._wait_timer = self._makeIntAttribute(attributes["wait_timer"]) diff --git a/github/EnvironmentProtectionRuleReviewer.py b/github/EnvironmentProtectionRuleReviewer.py new file mode 100644 index 00000000..9ddfb3c6 --- /dev/null +++ b/github/EnvironmentProtectionRuleReviewer.py @@ -0,0 +1,80 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Alson van der Meulen # +# # +# 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 . # +# # +################################################################################ + +from __future__ import annotations + +import github.GithubObject +import github.NamedUser +import github.Team + + +class EnvironmentProtectionRuleReviewer(github.GithubObject.NonCompletableGithubObject): + """ + This class represents a reviewer for an EnvironmentProtectionRule. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments + """ + + def __repr__(self): + return self.get__repr__({"type": self._type.value}) + + @property + def type(self) -> str: + return self._type.value + + @property + def reviewer(self) -> github.NamedUser.NamedUser | github.Team.Team: + return self._reviewer.value + + def _initAttributes(self): + self._type = github.GithubObject.NotSet + self._reviewer = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) + if "reviewer" in attributes: # pragma no branch + assert self._type.value in ("User", "Team") + if self._type.value == "User": + self._reviewer = self._makeClassAttribute( + github.NamedUser.NamedUser, attributes["reviewer"] + ) + elif self._type.value == "Team": + self._reviewer = self._makeClassAttribute( + github.Team.Team, attributes["reviewer"] + ) + + +class ReviewerParams: + """ + This class presents reviewers as can be configured for an Environment. + """ + + def __init__(self, type_: str, id_: int): + assert isinstance(type_, str) and type_ in ("User", "Team") + assert isinstance(id_, int) + self.type = type_ + self.id = id_ + + def _asdict(self) -> dict: + return { + "type": self.type, + "id": self.id, + } diff --git a/github/Repository.py b/github/Repository.py index 7baef948..9e84080a 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -100,6 +100,7 @@ # Copyright 2022 Ibrahim Hussaini # # Copyright 2022 KimSia Sim <245021+simkimsia@users.noreply.github.com> # # Copyright 2022 Marco Köpcke # +# Copyright 2022 Alson van der Meulen # # Copyright 2023 Jonathan Leitschuh # # Copyright 2023 Sol Redfern <59831933+Tsuesun@users.noreply.github.com> # # Copyright 2023 Mikhail f. Shiryaev # @@ -143,6 +144,10 @@ import github.Comparison import github.ContentFile import github.Deployment import github.Download +import github.Environment +import github.EnvironmentDeploymentBranchPolicy +import github.EnvironmentProtectionRule +import github.EnvironmentProtectionRuleReviewer import github.Event import github.GitBlob import github.GitCommit @@ -4103,6 +4108,95 @@ class Repository(github.GithubObject.CompletableGithubObject): None, ) + def get_environments(self): + """ + :calls: `GET /repos/{owner}/{repo}/environments `_ + :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Environment.Environment` + """ + return github.PaginatedList.PaginatedList( + github.Environment.Environment, + self._requester, + f"{self.url}/environments", + None, + list_item="environments", + ) + + def get_environment(self, environment_name): + """ + :calls: `GET /repos/{owner}/{repo}/environments/{environment_name} `_ + :rtype: :class:`github.Environment.Environment` + """ + assert isinstance(environment_name, str), environment_name + headers, data = self._requester.requestJsonAndCheck( + "GET", f"{self.url}/environments/{environment_name}" + ) + return github.Environment.Environment( + self._requester, headers, data, completed=True + ) + + def create_environment( + self, + environment_name, + wait_timer=0, + reviewers=[], + deployment_branch_policy=None, + ): + """ + :calls: `PUT /repos/{owner}/{repo}/environments/{environment_name} `_ + :param environment_name: string + :param wait_timer: int + :param reviews: List[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams] + :param deployment_branch_policy: Optional[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams`] + :rtype: :class:`github.Environment.Environment` + """ + assert isinstance(environment_name, str), environment_name + assert isinstance(wait_timer, int) + assert isinstance(reviewers, list) + assert all( + [ + isinstance( + reviewer, github.EnvironmentProtectionRuleReviewer.ReviewerParams + ) + for reviewer in reviewers + ] + ) + assert ( + isinstance( + deployment_branch_policy, + github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams, + ) + or deployment_branch_policy is None + ) + + put_parameters = { + "wait_timer": wait_timer, + "reviewers": [reviewer._asdict() for reviewer in reviewers], + "deployment_branch_policy": deployment_branch_policy._asdict() + if deployment_branch_policy + else None, + } + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/environments/{environment_name}", input=put_parameters + ) + return github.Environment.Environment( + self._requester, headers, data, completed=True + ) + + update_environment = create_environment + + def delete_environment(self, environment_name): + """ + :calls: `DELETE /repos/{owner}/{repo}/environments/{environment_name} `_ + :param environment_name: string + :rtype: None + """ + assert isinstance(environment_name, str), environment_name + + headers, data = self._requester.requestJsonAndCheck( + "DELETE", f"{self.url}/environments/{environment_name}" + ) + def _initAttributes(self): self._allow_auto_merge = github.GithubObject.NotSet self._allow_forking = github.GithubObject.NotSet diff --git a/github/Repository.pyi b/github/Repository.pyi index 3d1fbf0c..17dce8a6 100644 --- a/github/Repository.pyi +++ b/github/Repository.pyi @@ -14,6 +14,11 @@ from github.Comparison import Comparison from github.ContentFile import ContentFile from github.Deployment import Deployment from github.Download import Download +from github.Environment import Environment +from github.EnvironmentDeploymentBranchPolicy import ( + EnvironmentDeploymentBranchPolicyParams, +) +from github.EnvironmentProtectionRuleReviewer import ReviewerParams from github.Event import Event from github.GitBlob import GitBlob from github.GitCommit import GitCommit @@ -142,6 +147,15 @@ class Repository(CompletableGithubObject): ) -> Deployment: ... def get_repository_advisories(self) -> PaginatedList[RepositoryAdvisory]: ... def get_repository_advisory(self, ghsa: str) -> RepositoryAdvisory: ... + def create_environment( + self, + environment_name: str, + wait_timer: int = ..., + reviewers: List[ReviewerParams] = ..., + deployment_branch_policy: Optional[ + EnvironmentDeploymentBranchPolicyParams + ] = ..., + ) -> Environment: ... def create_file( self, path: str, @@ -287,6 +301,7 @@ class Repository(CompletableGithubObject): @property def default_branch(self) -> str: ... def delete(self) -> None: ... + def delete_environment(self, environment_name: str) -> None: ... def delete_file( self, path: str, @@ -392,6 +407,8 @@ class Repository(CompletableGithubObject): ) -> List[ContentFile]: ... def get_download(self, id: int) -> Download: ... def get_downloads(self) -> PaginatedList[Download]: ... + def get_environments(self) -> PaginatedList[Environment]: ... + def get_environment(self, environment_name: str) -> Environment: ... def get_events(self) -> PaginatedList[Event]: ... def get_forks(self) -> PaginatedList[Repository]: ... def create_fork( @@ -644,6 +661,15 @@ class Repository(CompletableGithubObject): @property def trees_url(self) -> str: ... def unsubscribe_from_hub(self, event: str, callback: str) -> None: ... + def update_environment( + self, + environment_name: str, + wait_timer: int = ..., + reviewers: List[ReviewerParams] = ..., + deployment_branch_policy: Optional[ + EnvironmentDeploymentBranchPolicyParams + ] = ..., + ) -> Environment: ... def update_file( self, path: str, diff --git a/tests/Environment.py b/tests/Environment.py new file mode 100644 index 00000000..b540fb51 --- /dev/null +++ b/tests/Environment.py @@ -0,0 +1,179 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Alson van der Meulen # +# # +# 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 . # +# # +################################################################################ + +import datetime + +import pytest # type: ignore + +import github +import github.EnvironmentDeploymentBranchPolicy +import github.EnvironmentProtectionRule +import github.EnvironmentProtectionRuleReviewer +import github.NamedUser +import github.Team + +from . import Framework + + +class Environment(Framework.TestCase): + def setUp(self): + self.tokenAuthMode = True + super().setUp() + self.repo = self.g.get_user().get_repo("PyGithub") + self.environment = self.repo.get_environment("dev") + + def testAttributes(self): + self.assertEqual(self.environment.name, "dev") + self.assertEqual(self.environment.id, 464814513) + self.assertEqual(self.environment.node_id, "EN_kwDOHKhL9c4btIGx") + self.assertEqual( + self.environment.url, + "https://api.github.com/repos/alson/PyGithub/environments/dev", + ) + self.assertEqual( + self.environment.html_url, + "https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev", + ) + self.assertEqual( + self.environment.created_at, datetime.datetime(2022, 4, 13, 15, 6, 32) + ) + self.assertEqual( + self.environment.updated_at, datetime.datetime(2022, 4, 13, 15, 6, 32) + ) + self.assertTrue(self.environment.deployment_branch_policy.protected_branches) + self.assertFalse( + self.environment.deployment_branch_policy.custom_branch_policies + ) + + def testProtectionRules(self): + protection_rules = self.environment.protection_rules + self.assertEqual(len(protection_rules), 3) + self.assertEqual(protection_rules[0].id, 216323) + self.assertEqual(protection_rules[0].node_id, "GA_kwDOHKhL9c4AA00D") + self.assertEqual(protection_rules[0].type, "branch_policy") + self.assertEqual(protection_rules[1].id, 216324) + self.assertEqual(protection_rules[1].node_id, "GA_kwDOHKhL9c4AA00E") + self.assertEqual(protection_rules[1].type, "required_reviewers") + self.assertEqual(protection_rules[2].id, 216325) + self.assertEqual(protection_rules[2].node_id, "GA_kwDOHKhL9c4AA00F") + self.assertEqual(protection_rules[2].type, "wait_timer") + self.assertEqual(protection_rules[2].wait_timer, 15) + + def testReviewers(self): + # This is necessary so we can maintain our own expectations, which have been manually editted, for this test. + reviewers = self.repo.get_environment("dev").protection_rules[1].reviewers + self.assertEqual(len(reviewers), 2) + self.assertEqual(reviewers[0].type, "User") + self.assertIsInstance(reviewers[0].reviewer, github.NamedUser.NamedUser) + assert isinstance( + reviewers[0].reviewer, github.NamedUser.NamedUser + ) # Make type checker happy + self.assertEqual(reviewers[0].reviewer.id, 19245) + self.assertEqual(reviewers[0].reviewer.login, "alson") + self.assertEqual(reviewers[0].reviewer.type, "User") + self.assertEqual(reviewers[1].type, "Team") + self.assertIsInstance(reviewers[1].reviewer, github.Team.Team) + assert isinstance( + reviewers[1].reviewer, github.Team.Team + ) # Make type checker happy + self.assertEqual(reviewers[1].reviewer.id, 1) + self.assertEqual(reviewers[1].reviewer.slug, "justice-league") + self.assertEqual(reviewers[1].reviewer.url, "https://api.github.com/teams/1") + + def testGetEnvironments(self): + environments = self.repo.get_environments() + self.assertEqual(environments.totalCount, 1) + self.assertEqual( + environments[0].url, + "https://api.github.com/repos/alson/PyGithub/environments/dev", + ) + self.assertEqual(environments[0].name, "dev") + + def testCreateEnvironment(self): + environment = self.repo.create_environment("test") + self.assertEqual(environment.name, "test") + self.assertEqual(environment.id, 470015651) + self.assertEqual(environment.node_id, "EN_kwDOHKhL9c4cA96j") + self.assertEqual( + environment.url, + "https://api.github.com/repos/alson/PyGithub/environments/test", + ) + self.assertEqual( + environment.html_url, + "https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test", + ) + self.assertEqual( + environment.created_at, datetime.datetime(2022, 4, 19, 14, 4, 32) + ) + self.assertEqual( + environment.updated_at, datetime.datetime(2022, 4, 19, 14, 4, 32) + ) + self.assertEqual(len(environment.protection_rules), 0) + self.assertIsNone(environment.deployment_branch_policy) + + def testUpdateEnvironment(self): + environment = self.repo.create_environment( + "test", + wait_timer=42, + reviewers=[ + github.EnvironmentProtectionRuleReviewer.ReviewerParams( + type_="User", id_=19245 + ) + ], + deployment_branch_policy=github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams( + protected_branches=True, custom_branch_policies=False + ), + ) + self.assertEqual(environment.name, "test") + self.assertEqual(environment.id, 470015651) + self.assertEqual(environment.node_id, "EN_kwDOHKhL9c4cA96j") + self.assertEqual( + environment.url, + "https://api.github.com/repos/alson/PyGithub/environments/test", + ) + self.assertEqual( + environment.html_url, + "https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test", + ) + self.assertEqual( + environment.created_at, datetime.datetime(2022, 4, 19, 14, 4, 32) + ) + self.assertEqual( + environment.updated_at, datetime.datetime(2022, 4, 19, 14, 4, 32) + ) + self.assertEqual(len(environment.protection_rules), 3) + self.assertEqual(environment.protection_rules[0].type, "required_reviewers") + self.assertEqual(len(environment.protection_rules[0].reviewers), 1) + self.assertEqual(environment.protection_rules[0].reviewers[0].type, "User") + self.assertEqual( + environment.protection_rules[0].reviewers[0].reviewer.id, 19245 + ) + self.assertEqual(environment.protection_rules[1].type, "wait_timer") + self.assertEqual(environment.protection_rules[1].wait_timer, 42) + self.assertEqual(environment.protection_rules[2].type, "branch_policy") + self.assertTrue(environment.deployment_branch_policy.protected_branches) + self.assertFalse(environment.deployment_branch_policy.custom_branch_policies) + + def testDeleteEnvironment(self): + self.repo.delete_environment("test") + with pytest.raises(github.UnknownObjectException): + self.repo.get_environment("test") diff --git a/tests/ReplayData/Environment.setUp.txt b/tests/ReplayData/Environment.setUp.txt new file mode 100644 index 00000000..40dc16d2 --- /dev/null +++ b/tests/ReplayData/Environment.setUp.txt @@ -0,0 +1,33 @@ +https +GET +api.github.com +None +/user +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:42 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"deb192848286d837e1a96d0d833bc7f7fa450e5c76fdb55353d9d99f92044c2f"'), ('Last-Modified', 'Mon, 11 Apr 2022 10:43:16 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4999'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '1'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'F375:EF17:1BDD7E:1CEDD7:62601246')] +{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false,"name":null,"company":null,"blog":"","location":null,"email":null,"hireable":null,"bio":null,"twitter_username":null,"public_repos":9,"public_gists":0,"followers":5,"following":0,"created_at":"2008-08-01T14:15:46Z","updated_at":"2022-04-11T10:43:16Z"} + +https +GET +api.github.com +None +/repos/alson/PyGithub +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:42 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"b9d5b0c5e350dee5ace25a78f5d53c601a0efb75b614f35aca41c37b329ec6de"'), ('Last-Modified', 'Wed, 20 Apr 2022 13:43:21 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', 'repo'), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4998'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '2'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'F376:9F57:EED29:FE724:62601246')] +{"id":480791541,"node_id":"R_kgDOHKhL9Q","name":"PyGithub","full_name":"alson/PyGithub","private":false,"owner":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false},"html_url":"https://github.com/alson/PyGithub","description":"Typed interactions with the GitHub API v3 (with support for Environments)","fork":true,"url":"https://api.github.com/repos/alson/PyGithub","forks_url":"https://api.github.com/repos/alson/PyGithub/forks","keys_url":"https://api.github.com/repos/alson/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alson/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alson/PyGithub/teams","hooks_url":"https://api.github.com/repos/alson/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/alson/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/alson/PyGithub/events","assignees_url":"https://api.github.com/repos/alson/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/alson/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/alson/PyGithub/tags","blobs_url":"https://api.github.com/repos/alson/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alson/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alson/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/alson/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alson/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/alson/PyGithub/languages","stargazers_url":"https://api.github.com/repos/alson/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/alson/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/alson/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/alson/PyGithub/subscription","commits_url":"https://api.github.com/repos/alson/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/alson/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/alson/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/alson/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/alson/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/alson/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alson/PyGithub/merges","archive_url":"https://api.github.com/repos/alson/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alson/PyGithub/downloads","issues_url":"https://api.github.com/repos/alson/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/alson/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/alson/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/alson/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alson/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/alson/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/alson/PyGithub/deployments","created_at":"2022-04-12T12:00:27Z","updated_at":"2022-04-20T13:43:21Z","pushed_at":"2022-04-20T13:43:11Z","git_url":"git://github.com/alson/PyGithub.git","ssh_url":"git@github.com:alson/PyGithub.git","clone_url":"https://github.com/alson/PyGithub.git","svn_url":"https://github.com/alson/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":13547,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"topics":[],"visibility":"public","forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"maintain":true,"push":true,"triage":true,"pull":true},"temp_clone_token":"","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"parent":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2022-04-20T13:58:31Z","pushed_at":"2022-04-12T12:36:44Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":13547,"stargazers_count":5203,"watchers_count":5203,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1478,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":148,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"topics":["github","github-api","pygithub","python"],"visibility":"public","forks":1478,"open_issues":148,"watchers":5203,"default_branch":"master"},"source":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2022-04-20T13:58:31Z","pushed_at":"2022-04-12T12:36:44Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":13547,"stargazers_count":5203,"watchers_count":5203,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1478,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":148,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"allow_forking":true,"is_template":false,"topics":["github","github-api","pygithub","python"],"visibility":"public","forks":1478,"open_issues":148,"watchers":5203,"default_branch":"master"},"network_count":1478,"subscribers_count":0} + +https +GET +api.github.com +None +/repos/alson/PyGithub/environments/dev +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:42 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"3b0433057350078e2272494ff1c150fd0063b57b11fad140ec6bf723991e9ebf"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4997'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '3'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'F37B:4620:7192EF:732DA7:62601246')] +{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}} + diff --git a/tests/ReplayData/Environment.testCreateEnvironment.txt b/tests/ReplayData/Environment.testCreateEnvironment.txt new file mode 100644 index 00000000..f7c13cdb --- /dev/null +++ b/tests/ReplayData/Environment.testCreateEnvironment.txt @@ -0,0 +1,11 @@ +https +PUT +api.github.com +None +/repos/alson/PyGithub/environments/test +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'} +{"wait_timer": 0, "reviewers": [], "deployment_branch_policy": null} +200 +[('Server', 'GitHub.com'), ('Date', 'Tue, 19 Apr 2022 14:04:32 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"551b8efc5f64e50c7aea535a16d55561640ea5649a4e1d349ed09f953cae96da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4993'), ('X-RateLimit-Reset', '1650380634'), ('X-RateLimit-Used', '7'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'C759:D172:956268:97BB8A:625EC170')] +{"id":470015651,"node_id":"EN_kwDOHKhL9c4cA96j","name":"test","url":"https://api.github.com/repos/alson/PyGithub/environments/test","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test","created_at":"2022-04-19T14:04:32Z","updated_at":"2022-04-19T14:04:32Z","protection_rules":[],"deployment_branch_policy":null} + diff --git a/tests/ReplayData/Environment.testDeleteEnvironment.txt b/tests/ReplayData/Environment.testDeleteEnvironment.txt new file mode 100644 index 00000000..bea1b73e --- /dev/null +++ b/tests/ReplayData/Environment.testDeleteEnvironment.txt @@ -0,0 +1,22 @@ +https +DELETE +api.github.com +None +/repos/alson/PyGithub/environments/test +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +204 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:43 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4996'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '4'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('X-GitHub-Request-Id', 'F37C:EF19:493413:4A9458:62601246')] + + +https +GET +api.github.com +None +/repos/alson/PyGithub/environments/test +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +404 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:43 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4995'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '5'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'F37D:1385E:70D68B:727E0B:62601247')] +{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-an-environment"} + diff --git a/tests/ReplayData/Environment.testGetEnvironments.txt b/tests/ReplayData/Environment.testGetEnvironments.txt new file mode 100644 index 00000000..a8320bd3 --- /dev/null +++ b/tests/ReplayData/Environment.testGetEnvironments.txt @@ -0,0 +1,22 @@ +https +GET +api.github.com +None +/repos/alson/PyGithub/environments?per_page=1 +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 18:02:57 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"ed85111e774379ffa08c34657bedabffff15a4f8e053b94cc89adc52e7f771da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4837'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '163'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D7DE:34F1:419DBE:43183F:62571051')] +{"total_count":1,"environments":[{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}]} + +https +GET +api.github.com +None +/repos/alson/PyGithub/environments +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 18:02:57 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"ed85111e774379ffa08c34657bedabffff15a4f8e053b94cc89adc52e7f771da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4836'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '164'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D7DF:12F27:1358BD:147359:62571051')] +{"total_count":1,"environments":[{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}]} + diff --git a/tests/ReplayData/Environment.testReviewers.txt b/tests/ReplayData/Environment.testReviewers.txt new file mode 100644 index 00000000..1bc4f361 --- /dev/null +++ b/tests/ReplayData/Environment.testReviewers.txt @@ -0,0 +1,11 @@ +https +GET +api.github.com +None +/repos/alson/PyGithub/environments/dev +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 17:40:18 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"3b0433057350078e2272494ff1c150fd0063b57b11fad140ec6bf723991e9ebf"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4915'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '85'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D6B6:B7D7:1419EA:151E71:62570B02')] +{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}, {"type":"Team","reviewer":{"id":1,"node_id":"MDQ6VGVhbTE=","url":"https://api.github.com/teams/1","html_url":"https://github.com/orgs/github/teams/justice-league","name":"Justice League","slug":"justice-league","description":"A great team.","privacy":"closed","permission":"admin","members_url":"https://api.github.com/teams/1/members{/member}","repositories_url":"https://api.github.com/teams/1/repos","parent":null}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}} + diff --git a/tests/ReplayData/Environment.testUpdateEnvironment.txt b/tests/ReplayData/Environment.testUpdateEnvironment.txt new file mode 100644 index 00000000..6cfef082 --- /dev/null +++ b/tests/ReplayData/Environment.testUpdateEnvironment.txt @@ -0,0 +1,11 @@ +https +PUT +api.github.com +None +/repos/alson/PyGithub/environments/test +{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'} +{"wait_timer": 42, "reviewers": [{"type": "User", "id": 19245}], "deployment_branch_policy": {"protected_branches": true, "custom_branch_policies": false}} +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 10:41:27 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"6a0e8d2fa745fa04719de5c68f6535950341c778998f7979827ab4a865451879"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4992'), ('X-RateLimit-Reset', '1650454681'), ('X-RateLimit-Used', '8'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D0C7:FF6E:A162C:A41FF:625FE356')] +{"id":470015651,"node_id":"EN_kwDOHKhL9c4cA96j","name":"test","url":"https://api.github.com/repos/alson/PyGithub/environments/test","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test","created_at":"2022-04-19T14:04:32Z","updated_at":"2022-04-19T14:04:32Z","protection_rules":[{"id":222463,"node_id":"GA_kwDOHKhL9c4AA2T_","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":222464,"node_id":"GA_kwDOHKhL9c4AA2UA","type":"wait_timer","wait_timer":42},{"id":222465,"node_id":"GA_kwDOHKhL9c4AA2UB","type":"branch_policy"}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}} +