File tree Expand file tree Collapse file tree 6 files changed +550
-13
lines changed Expand file tree Collapse file tree 6 files changed +550
-13
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,20 @@ jobs:
3030 run : touch .env
3131
3232 - name : " Run validation & test"
33- run : docker compose run --service-ports app_test
33+ run : docker compose run --service-ports app_test bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check && pytest --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT tests/unit"
34+ env :
35+ RP_LAUNCH : github-unit-test
36+ RP_ENDPOINT : ${{ secrets.RP_ENDPOINT }}
37+ RP_API_KEY : ${{ secrets.RP_API_KEY }}
3438
3539 - name : " Run E2E test"
36- run : docker compose run --service-ports -e MPT_API_BASE_URL=$MPT_API_BASE_URL -e MPT_API_TOKEN=$MPT_API_TOKEN e2e
40+ run : docker compose run --service-ports e2e bash -c "pytest --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT tests/ e2e"
3741 env :
3842 MPT_API_BASE_URL : ${{ secrets.MPT_API_BASE_URL }}
3943 MPT_API_TOKEN : ${{ secrets.MPT_API_TOKEN }}
44+ RP_LAUNCH : github-e2e-test
45+ RP_ENDPOINT : ${{ secrets.RP_ENDPOINT }}
46+ RP_API_KEY : ${{ secrets.RP_API_KEY }}
4047
4148
4249 - name : " Run SonarCloud Scan"
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ services:
1818 context : .
1919 dockerfile : dev.Dockerfile
2020 working_dir : /mpt_api_client
21- command : bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check && pytest"
21+ command : bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check && pytest tests/unit "
2222 volumes :
2323 - .:/mpt_api_client
2424
@@ -52,7 +52,7 @@ services:
5252 context : .
5353 dockerfile : dev.Dockerfile
5454 working_dir : /mpt_api_client
55- command : bash -c "pytest -m e2e - p no:randomly --junitxml=e2e-report.xml"
55+ command : bash -c "pytest -p no:randomly --junitxml=e2e-report.xml tests/e2e "
5656 volumes :
5757 - .:/mpt_api_client
5858 env_file :
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ dev = [
3737 " pytest-deadfixtures==2.2.*" ,
3838 " pytest-mock==3.14.*" ,
3939 " pytest-randomly==3.16.*" ,
40+ " pytest-reportportal>=5.5.2" ,
4041 " pytest-rerunfailures>=16.1" ,
4142 " pytest-xdist==3.6.*" ,
4243 " responses==0.25.*" ,
@@ -59,17 +60,15 @@ build-backend = "hatchling.build"
5960[tool .pytest .ini_options ]
6061testpaths = " tests"
6162pythonpath = " ."
62- addopts = " --cov=mpt_api_client --cov-report=term-missing --cov-report=html --cov-report=xml --import-mode=importlib -m 'not e2e' "
63+ addopts = " --cov=mpt_api_client --cov-report=term-missing --cov-report=html --cov-report=xml --import-mode=importlib"
6364log_cli = false
6465asyncio_mode = " auto"
6566asyncio_default_fixture_loop_scope = " function"
6667filterwarnings = [
6768 " ignore:Support for class-based `config` is deprecated:DeprecationWarning" ,
6869 " ignore:pkg_resources is deprecated as an API:DeprecationWarning" ,
6970]
70- markers = [
71- " e2e: marks tests as e2e"
72- ]
71+ rp_project = " mpt-api-python-client"
7372
7473[tool .coverage .run ]
7574branch = true
Original file line number Diff line number Diff line change 1+ import logging
12import os
23
34import pytest
5+ from reportportal_client import RPLogger
46
57from mpt_api_client import MPTClient
68
@@ -18,3 +20,11 @@ def base_url():
1820@pytest .fixture
1921def mpt_client (api_token , base_url ):
2022 return MPTClient .from_config (api_token = api_token , base_url = base_url )
23+
24+
25+ @pytest .fixture (scope = "session" )
26+ def logger ():
27+ logger = logging .getLogger (__name__ )
28+ logger .setLevel (logging .DEBUG )
29+ logging .setLoggerClass (RPLogger )
30+ return logger
Original file line number Diff line number Diff line change 77
88
99@pytest .mark .flaky (reruns = 5 , reruns_delay = 0.01 ) # noqa: WPS432
10- @pytest .mark .e2e
11- def test_example ():
12- assert random .choice ([True , False ]) # noqa: S311
10+ def test_example (logger ):
11+ choice = random .choice ([True , False ]) # noqa: S311
12+ logger .info ("Choice: %s" , choice )
13+ assert choice is True
1314
1415
1516@pytest .mark .flaky
16- @pytest .mark .e2e
1717def test_unauthorised (base_url ):
1818 client = MPTClient .from_config (api_token = "TKN-invalid" , base_url = base_url ) # noqa: S106
1919
@@ -22,7 +22,6 @@ def test_unauthorised(base_url):
2222
2323
2424@pytest .mark .flaky
25- @pytest .mark .e2e
2625def test_access (mpt_client ):
2726 product = mpt_client .catalog .products .get ("PRD-1975-5250" )
2827 assert product .id == "PRD-1975-5250"
You can’t perform that action at this time.
0 commit comments