Skip to content

Commit d01664b

Browse files
committed
refactor(tests): make functional tests use the pytest-gitlab plugin
Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
1 parent ef7827a commit d01664b

15 files changed

+9
-913
lines changed

CONTRIBUTING.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ To run these tests:
153153
154154
When developing tests it can be a little frustrating to wait for GitLab to spin
155155
up every run. To prevent the containers from being cleaned up afterwards, pass
156-
``--keep-containers`` to pytest, i.e.:
156+
``--keep-containers-running`` to pytest, i.e.:
157157

158158
.. code-block:: bash
159159
160-
tox -e api_func_v4 -- --keep-containers
160+
tox -e api_func_v4 -- --keep-containers-running
161161
162162
If you then wish to test against a clean slate, you may perform a manual clean
163163
up of the containers by running:
164164

165165
.. code-block:: bash
166166
167-
docker-compose -f tests/functional/fixtures/docker-compose.yml -p pytest-python-gitlab down -v
167+
docker-compose -f gitlab/testing/docker/docker-compose.yml -p pytest-python-gitlab down -v
168168
169169
By default, the tests run against the latest version of the ``gitlab/gitlab-ce``
170170
image. You can override both the image and tag by providing either the

requirements-docker.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
-r requirements.txt
22
-r requirements-test.txt
3-
pytest-docker==3.2.5

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pytest-console-scripts==1.4.1
66
pytest-cov==7.0.0
77
pytest-github-actions-annotate-failures==0.3.0
88
pytest==9.0.2
9+
pytest-docker==3.2.5
910
PyYaml==6.0.3
1011
responses==0.25.8
1112
respx==0.22.0

tests/conftest.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,7 @@
33
import _pytest.config
44
import pytest
55

6-
import gitlab
7-
86

97
@pytest.fixture(scope="session")
108
def test_dir(pytestconfig: _pytest.config.Config) -> pathlib.Path:
119
return pytestconfig.rootdir / "tests" # type: ignore
12-
13-
14-
@pytest.fixture(autouse=True)
15-
def mock_clean_config(monkeypatch: pytest.MonkeyPatch) -> None:
16-
"""Ensures user-defined environment variables do not interfere with tests."""
17-
monkeypatch.delenv("PYTHON_GITLAB_CFG", raising=False)
18-
monkeypatch.delenv("GITLAB_PRIVATE_TOKEN", raising=False)
19-
monkeypatch.delenv("GITLAB_URL", raising=False)
20-
monkeypatch.delenv("CI_JOB_TOKEN", raising=False)
21-
monkeypatch.delenv("CI_SERVER_URL", raising=False)
22-
23-
24-
@pytest.fixture(autouse=True)
25-
def default_files(monkeypatch: pytest.MonkeyPatch) -> None:
26-
"""Ensures user configuration files do not interfere with tests."""
27-
monkeypatch.setattr(gitlab.config, "_DEFAULT_FILES", [])
28-
29-
30-
@pytest.fixture
31-
def valid_gitlab_ci_yml() -> str:
32-
return """---
33-
:test_job:
34-
:script: echo 1
35-
"""
36-
37-
38-
@pytest.fixture
39-
def invalid_gitlab_ci_yml() -> str:
40-
return "invalid"

0 commit comments

Comments
 (0)