diff options
author | Mitar <mitar.git@tnode.com> | 2019-12-12 22:08:58 -0800 |
---|---|---|
committer | Mitar <mitar.git@tnode.com> | 2019-12-12 22:16:40 -0800 |
commit | 8760efc89bac394b01218b48dd3fcbef30c8b9a2 (patch) | |
tree | b46e82fd202ece92f2bb77f84955ebe59ba8230d /gitlab/tests/test_gitlab.py | |
parent | 8c84cbf6374e466f21d175206836672b3dadde20 (diff) | |
download | gitlab-8760efc89bac394b01218b48dd3fcbef30c8b9a2.tar.gz |
test: added tests for statistics
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index 7449b3a..5bf373a 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -553,6 +553,62 @@ class TestGitlab(unittest.TestCase): self.assertEqual(environment.last_deployment, "sometime") self.assertEqual(environment.name, "environment_name") + def test_project_additional_statistics(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/statistics", + method="get", + ) + def resp_get_environment(url, request): + headers = {"content-type": "application/json"} + content = """{"fetches": {"total": 50, "days": [{"count": 10, "date": "2018-01-10"}]}}""".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) + statistics = project.additionalstatistics.get() + self.assertIsInstance(statistics, ProjectAdditionalStatistics) + self.assertEqual(statistics.fetches["total"], 50) + + def test_project_issues_statistics(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/issues_statistics", + method="get", + ) + def resp_get_environment(url, request): + headers = {"content-type": "application/json"} + content = """{"statistics": {"counts": {"all": 20, "closed": 5, "opened": 15}}}""".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) + statistics = project.issuesstatistics.get() + self.assertIsInstance(statistics, ProjectIssuesStatistics) + self.assertEqual(statistics.statistics["counts"]["all"], 20) + def test_groups(self): @urlmatch( scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get" |