Skip to content

Commit 055ee99

Browse files
committed
MPT-14713 Prepare for e2e testing
1 parent ca93d0c commit 055ee99

File tree

118 files changed

+84
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+84
-23
lines changed

.github/workflows/pr-build-merge.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: "Run validation & test"
3030
run: docker compose run --service-ports app_test
3131

32+
- name: "Run E2E test"
33+
run: docker compose run --service-ports app_test
34+
3235
- name: "Run SonarCloud Scan"
3336
uses: SonarSource/sonarqube-scan-action@master
3437
env:

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ services:
4141
command: bash -c "ruff check . --select I --fix && ruff format ."
4242
volumes:
4343
- .:/mpt_api_client
44+
45+
e2e:
46+
container_name: mpt_api_client_test
47+
build:
48+
context: .
49+
dockerfile: dev.Dockerfile
50+
working_dir: /mpt_api_client
51+
command: bash -c "pytest -m e2e -p no:randomly --junitxml=e2e-report.xml"
52+
volumes:
53+
- .:/mpt_api_client

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ dev = [
3737
"pytest-deadfixtures==2.2.*",
3838
"pytest-mock==3.14.*",
3939
"pytest-randomly==3.16.*",
40+
"pytest-rerunfailures>=16.1",
4041
"pytest-xdist==3.6.*",
4142
"responses==0.25.*",
4243
"respx==0.22.*",
43-
"ruff==0.12.11", # force ruff version to have same formatting everywhere
44+
"ruff==0.12.11", # force ruff version to have same formatting everywhere
4445
"typing-extensions==4.13.*",
4546
"wemake-python-styleguide==1.3.*",
4647
]
@@ -58,13 +59,16 @@ build-backend = "hatchling.build"
5859
[tool.pytest.ini_options]
5960
testpaths = "tests"
6061
pythonpath = "."
61-
addopts = "--cov=mpt_api_client --cov-report=term-missing --cov-report=html --cov-report=xml --import-mode=importlib"
62+
addopts = "--cov=mpt_api_client --cov-report=term-missing --cov-report=html --cov-report=xml --import-mode=importlib -m 'not e2e'"
6263
log_cli = false
6364
asyncio_mode = "auto"
6465
filterwarnings = [
6566
"ignore:Support for class-based `config` is deprecated:DeprecationWarning",
6667
"ignore:pkg_resources is deprecated as an API:DeprecationWarning",
6768
]
69+
markers = [
70+
"e2e: marks tests as e2e"
71+
]
6872

6973
[tool.coverage.run]
7074
branch = true

setup.cfg

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ per-file-ignores =
4040
mpt_api_client/resources/catalog/*.py: WPS110 WPS214 WPS215
4141
mpt_api_client/resources/catalog/products.py: WPS204 WPS214 WPS215
4242
mpt_api_client/rql/query_builder.py: WPS110 WPS115 WPS210 WPS214
43-
tests/http/test_async_service.py: WPS204 WPS202
44-
tests/http/test_service.py: WPS204 WPS202
45-
tests/http/test_mixins.py: WPS204 WPS202
46-
tests/resources/catalog/test_products.py: WPS202 WPS210
47-
tests/resources/*/test_mixins.py: WPS118 WPS202 WPS204 WPS235
48-
tests/resources/accounts/test_users.py: WPS204 WPS202 WPS210
49-
tests/test_mpt_client.py: WPS235
50-
51-
tests/*:
43+
tests/unit/http/test_async_service.py: WPS204 WPS202
44+
tests/unit/http/test_service.py: WPS204 WPS202
45+
tests/unit/http/test_mixins.py: WPS204 WPS202
46+
tests/unit/resources/catalog/test_products.py: WPS202 WPS210
47+
tests/unit/resources/*/test_mixins.py: WPS118 WPS202 WPS204 WPS235
48+
tests/unit/resources/accounts/test_users.py: WPS204 WPS202 WPS210
49+
tests/unit/test_mpt_client.py: WPS235
50+
51+
tests/unit/*:
5252
# Allow magic strings.
5353
WPS432
5454
# Found too many modules members.

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ sonar.inclusions=mpt_api_client/**
99
sonar.exclusions=tests/**,**/__init__.py
1010

1111
sonar.python.coverage.reportPaths=coverage.xml
12-
sonar.python.xunit.reportPath=coverage.xml
12+
sonar.python.xunit.reportPath=coverage.xml,e2e-report.xml
1313
sonar.python.version=3

tests/e2e/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
3+
import pytest
4+
5+
from mpt_api_client import MPTClient
6+
7+
8+
@pytest.fixture
9+
def api_token():
10+
return os.getenv("API_TOKEN")
11+
12+
13+
@pytest.fixture
14+
def base_url():
15+
return os.getenv("API_URL")
16+
17+
18+
@pytest.fixture
19+
def mpt_client(api_token, base_url):
20+
return MPTClient.from_config(api_token=api_token, base_url=base_url)

tests/e2e/test_e2e.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import random
2+
3+
import pytest
4+
5+
6+
@pytest.mark.flaky(reruns=5, reruns_delay=0.01) # noqa: WPS432
7+
@pytest.mark.e2e
8+
def test_example():
9+
assert random.choice([True, False]) # noqa: S311

0 commit comments

Comments
 (0)