Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0389e66

Browse filesBrowse files
authored
Merge pull request python-gitlab#865 from orf/retrieve-environment
feat: add methods to retrieve an individual project environment
2 parents 99a9415 + 29de40e commit 0389e66
Copy full SHA for 0389e66

File tree

Expand file treeCollapse file tree

3 files changed

+35
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+35
-1
lines changed
Open diff view settings
Collapse file

‎docs/gl_objects/environments.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/environments.rst
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Create an environment for a project::
2424

2525
environment = project.environments.create({'name': 'production'})
2626

27+
Retrieve a specific environment for a project::
28+
29+
environment = project.environments.get(112)
30+
2731
Update an environment for a project::
2832

2933
environment.external_url = 'http://foo.bar.com'
Collapse file

‎gitlab/tests/test_gitlab.py‎

Copy file name to clipboardExpand all lines: gitlab/tests/test_gitlab.py
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,36 @@ def resp_get_project(url, request):
556556
self.assertEqual(data.name, "name")
557557
self.assertEqual(data.id, 1)
558558

559+
def test_project_environments(self):
560+
@urlmatch(
561+
scheme="http", netloc="localhost", path="/api/v4/projects/1$", method="get"
562+
)
563+
def resp_get_project(url, request):
564+
headers = {"content-type": "application/json"}
565+
content = '{"name": "name", "id": 1}'.encode("utf-8")
566+
return response(200, content, headers, None, 5, request)
567+
568+
@urlmatch(
569+
scheme="http",
570+
netloc="localhost",
571+
path="/api/v4/projects/1/environments/1",
572+
method="get",
573+
)
574+
def resp_get_environment(url, request):
575+
headers = {"content-type": "application/json"}
576+
content = '{"name": "environment_name", "id": 1, "last_deployment": "sometime"}'.encode(
577+
"utf-8"
578+
)
579+
return response(200, content, headers, None, 5, request)
580+
581+
with HTTMock(resp_get_project, resp_get_environment):
582+
project = self.gl.projects.get(1)
583+
environment = project.environments.get(1)
584+
self.assertIsInstance(environment, ProjectEnvironment)
585+
self.assertEqual(environment.id, 1)
586+
self.assertEqual(environment.last_deployment, "sometime")
587+
self.assertEqual(environment.name, "environment_name")
588+
559589
def test_groups(self):
560590
@urlmatch(
561591
scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get"
Collapse file

‎gitlab/v4/objects.py‎

Copy file name to clipboardExpand all lines: gitlab/v4/objects.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ def stop(self, **kwargs):
19441944

19451945

19461946
class ProjectEnvironmentManager(
1947-
ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
1947+
RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
19481948
):
19491949
_path = "/projects/%(project_id)s/environments"
19501950
_obj_cls = ProjectEnvironment

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.