File tree Expand file tree Collapse file tree 6 files changed +558
-41
lines changed Expand file tree Collapse file tree 6 files changed +558
-41
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,22 @@ jobs:
2727 run : docker compose build app_test
2828
2929 - name : " Create environment file"
30- run : touch .env
30+ run : env | grep -E '^MPT_' > .env
31+ env :
32+ RP_ENDPOINT : ${{ secrets.RP_ENDPOINT }}
33+ RP_API_KEY : ${{ secrets.RP_API_KEY }}
34+ MPT_API_BASE_URL : ${{ secrets.MPT_API_BASE_URL }}
35+ MPT_API_TOKEN : ${{ secrets.MPT_API_TOKEN }}
3136
3237 - name : " Run validation & test"
3338 run : docker compose run --service-ports app_test
3439
3540 - 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
41+ run : docker compose run --service-ports app_test bash -c "pytest -p no:randomly --no-cov --reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT --junitxml= e2e-report.xml tests/e2e"
3742 env :
43+ RP_LAUNCH : github-e2e-test
44+ RP_ENDPOINT : ${{ secrets.RP_ENDPOINT }}
45+ RP_API_KEY : ${{ secrets.RP_API_KEY }}
3846 MPT_API_BASE_URL : ${{ secrets.MPT_API_BASE_URL }}
3947 MPT_API_TOKEN : ${{ secrets.MPT_API_TOKEN }}
4048
Original file line number Diff line number Diff line change @@ -12,22 +12,11 @@ services:
1212 env_file :
1313 - .env
1414
15- app_test :
16- container_name : mpt_api_client_test
17- build :
18- context : .
19- dockerfile : dev.Dockerfile
20- working_dir : /mpt_api_client
21- command : bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check && pytest"
22- volumes :
23- - .:/mpt_api_client
24-
25- bash :
26- container_name : mpt_api_client_bash
15+ bash : &dev_base
16+ image : mpt_api_client_dev
2717 build :
2818 context : .
2919 dockerfile : dev.Dockerfile
30- command : bash
3120 working_dir : /mpt_api_client
3221 stdin_open : true
3322 tty : true
@@ -36,24 +25,14 @@ services:
3625 env_file :
3726 - .env
3827
28+ app_test :
29+ << : *dev_base
30+ command : bash -c "ruff format --check . && ruff check . && flake8 . && mypy . && uv lock --check && pytest tests/unit"
31+
3932 format :
40- container_name : mpt_api_client_format
41- build :
42- context : .
43- dockerfile : dev.Dockerfile
44- working_dir : /mpt_api_client
33+ << : *dev_base
4534 command : bash -c "ruff check . --select I --fix && ruff format ."
46- volumes :
47- - .:/mpt_api_client
4835
4936 e2e :
50- container_name : mpt_api_client_test
51- build :
52- context : .
53- dockerfile : dev.Dockerfile
54- working_dir : /mpt_api_client
55- command : bash -c "pytest -m e2e -p no:randomly --junitxml=e2e-report.xml"
56- volumes :
57- - .:/mpt_api_client
58- env_file :
59- - .env
37+ << : *dev_base
38+ command : bash -c "pytest -p no:randomly --junitxml=e2e-report.xml tests/e2e"
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 rp_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 (rp_logger ):
11+ choice = random .choice ([True , False ]) # noqa: S311
12+ rp_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