conftest.py
- a module where setups pytest plugins and contains some base fixtures
fixtures/
- a directory with pytest fixtures, new module should be also added in conftest.pytest_plugins
mock_classes.py
- a module which contain base class with httpx
request method, setup logic for each test suite and HTTP status codes
../scripts/serialize_new_errata_rec.py
- a helper module for exporting/importing NewErrataRecords from a DB to json file.
-
Adjust variables in
vars.env
POSTGRES_DB="test-almalinux-bs" POSTGRES_PASSWORD="password" DATABASE_URL="postgresql+asyncpg://postgres:password@test_db/test-almalinux-bs" SYNC_DATABASE_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinux-bs" PULP_DATABASE_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinux-bs"
or use
test-vars.env
in thetests
folderln -sf tests/test-vars.env vars.env
-
Start the
test_db
servicedocker compose up -d test_db
-
To run packages_exporter tests start
sign-file
service and prepare GPG keys. tests/prepare_gpg_key.sh docker compose up -d sign_file
-
Update
tests/samples/new_errata_records.json
: Needed only on major changes inNewErrataRecord
model that affect OVAL generation.Note: In order to export data you'll need DB with some data,
ideally the data must be as similar to production as possible# set SQLALCHEMY_URL is it was not done on step 1 # export SQLALCHEMY_URL="postgresql+psycopg2://<your-db-address>" python3 scripts/serialize_new_errata_rec.py
Also, you'll need to update
tests/samples/test_oval.xml
.
For that uncomment block inside the test case intests/test_oval/test_oval_generation.py
file -
Run
pytest
withinweb_server_tests
containerdocker compose run --rm web_server_tests pytest -v