Skip to content

Files

Latest commit

8f3b8a3 · Jan 27, 2025

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 27, 2025
Jan 27, 2025
Dec 16, 2024
Jan 25, 2023
Jan 25, 2023
Jan 27, 2025
Jan 25, 2023
Oct 1, 2024
Aug 14, 2024
May 23, 2024
Dec 6, 2024
Jan 27, 2025
Nov 2, 2021
Jul 30, 2024
Jul 6, 2023
Sep 5, 2024
Sep 18, 2024
Apr 15, 2024
Sep 12, 2024

Unit tests

Content

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.

How to run tests locally

  1. 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 the tests folder

    ln -sf tests/test-vars.env vars.env
  2. Start the test_db service

    docker compose up -d test_db
  3. To run packages_exporter tests start sign-file service and prepare GPG keys

    . tests/prepare_gpg_key.sh
    docker compose up -d sign_file
  4. Update tests/samples/new_errata_records.json: Needed only on major changes in NewErrataRecord 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 in tests/test_oval/test_oval_generation.py file

  5. Run pytest within web_server_tests container

    docker compose run --rm web_server_tests pytest -v