diff options
| author | Max Wittig <max.wittig@siemens.com> | 2020-08-26 11:01:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-26 11:01:17 +0200 |
| commit | a7e44a0bb3629f776a52967d56ba67d9a61346eb (patch) | |
| tree | 24fb533a60a84e71386cc500d6ac2f00548f96ac /gitlab/tests/objects/conftest.py | |
| parent | e2dc9ece1a0af37073c41bfa8161fcec5fa01234 (diff) | |
| parent | 204782a117f77f367dee87aa2c70822587829147 (diff) | |
| download | gitlab-a7e44a0bb3629f776a52967d56ba67d9a61346eb.tar.gz | |
Merge pull request #1078 from python-gitlab/refactor/split-unit-tests
Refactor: split unit tests by API resources
Diffstat (limited to 'gitlab/tests/objects/conftest.py')
| -rw-r--r-- | gitlab/tests/objects/conftest.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gitlab/tests/objects/conftest.py b/gitlab/tests/objects/conftest.py new file mode 100644 index 0000000..76f76d1 --- /dev/null +++ b/gitlab/tests/objects/conftest.py @@ -0,0 +1,65 @@ +"""Common mocks for resources in gitlab.v4.objects""" + +import re + +import pytest +import responses + + +@pytest.fixture +def binary_content(): + return b"binary content" + + +@pytest.fixture +def accepted_content(): + return {"message": "202 Accepted"} + + +@pytest.fixture +def created_content(): + return {"message": "201 Created"} + + +@pytest.fixture +def resp_export(accepted_content, binary_content): + """Common fixture for group and project exports.""" + export_status_content = { + "id": 1, + "description": "Itaque perspiciatis minima aspernatur", + "name": "Gitlab Test", + "name_with_namespace": "Gitlab Org / Gitlab Test", + "path": "gitlab-test", + "path_with_namespace": "gitlab-org/gitlab-test", + "created_at": "2017-08-29T04:36:44.383Z", + "export_status": "finished", + "_links": { + "api_url": "https://gitlab.test/api/v4/projects/1/export/download", + "web_url": "https://gitlab.test/gitlab-test/download_export", + }, + } + + with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps: + rsps.add( + method=responses.POST, + url=re.compile(r".*/api/v4/(groups|projects)/1/export"), + json=accepted_content, + content_type="application/json", + status=202, + ) + rsps.add( + method=responses.GET, + url=re.compile(r".*/api/v4/(groups|projects)/1/export/download"), + body=binary_content, + content_type="application/octet-stream", + status=200, + ) + # Currently only project export supports status checks + rsps.add( + method=responses.GET, + url="http://localhost/api/v4/projects/1/export", + json=export_status_content, + content_type="application/json", + status=200, + ) + yield rsps |
