diff options
author | Tom Forbes <tom.forbes@onfido.com> | 2019-08-16 15:05:20 +0100 |
---|---|---|
committer | Tom Forbes <tom.forbes@onfido.com> | 2019-08-20 17:24:53 +0100 |
commit | 29de40ee6a20382c293d8cdc8d831b52ad56a657 (patch) | |
tree | 2adc3a081deb85abc70e30c2492112f2922db46a /gitlab/tests/test_gitlab.py | |
parent | e8a3585ed0e7dfa2f64f6c3378a598120f5f8167 (diff) | |
download | gitlab-29de40ee6a20382c293d8cdc8d831b52ad56a657.tar.gz |
feat: add methods to retrieve an individual project environment
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index c2b372a..ee1daa3 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -556,6 +556,36 @@ class TestGitlab(unittest.TestCase): self.assertEqual(data.name, "name") self.assertEqual(data.id, 1) + def test_project_environments(self): + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects/1$", method="get" + ) + def resp_get_project(url, request): + headers = {"content-type": "application/json"} + content = '{"name": "name", "id": 1}'.encode("utf-8") + return response(200, content, headers, None, 5, request) + + @urlmatch( + scheme="http", + netloc="localhost", + path="/api/v4/projects/1/environments/1", + method="get", + ) + def resp_get_environment(url, request): + headers = {"content-type": "application/json"} + content = '{"name": "environment_name", "id": 1, "last_deployment": "sometime"}'.encode( + "utf-8" + ) + return response(200, content, headers, None, 5, request) + + with HTTMock(resp_get_project, resp_get_environment): + project = self.gl.projects.get(1) + environment = project.environments.get(1) + self.assertIsInstance(environment, ProjectEnvironment) + self.assertEqual(environment.id, 1) + self.assertEqual(environment.last_deployment, "sometime") + self.assertEqual(environment.name, "environment_name") + def test_groups(self): @urlmatch( scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get" |