-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from opentargets/do_testing_start
feat: minimal testing suite
- Loading branch information
Showing
5 changed files
with
264 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Checks | ||
|
||
"on": | ||
pull_request: | ||
|
||
env: | ||
PYTHON_VERSION_DEFAULT: "3.10.8" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.10.8 | ||
- name: Install and configure Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION_DEFAULT }}-${{ hashFiles('**/poetry.lock') }} | ||
- name: Validate project dependencies | ||
run: poetry check | ||
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root | ||
- name: Install library | ||
run: poetry install --no-interaction | ||
- name: Check dependencies | ||
run: poetry run deptry . | ||
- name: Run tests | ||
run: poetry run pytest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Unit test configuration for the project.""" | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
from airflow.models import DagBag | ||
|
||
|
||
@pytest.fixture(params=["orchestration/dags"]) | ||
def dag_bag(request: pytest.FixtureRequest) -> DagBag: | ||
"""Return a DAG bag for testing.""" | ||
return DagBag(dag_folder=request.param, include_examples=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from airflow.models import DagBag | ||
|
||
|
||
def test_no_import_errors(dag_bag: DagBag) -> None: | ||
"""Test for import errors.""" | ||
assert ( | ||
not dag_bag.import_errors | ||
), f"DAG import failures. Errors: {dag_bag.import_errors}" | ||
|
||
|
||
def test_requires_tags(dag_bag: DagBag) -> None: | ||
"""Tags should be defined for each DAG.""" | ||
for _, dag in dag_bag.dags.items(): | ||
assert dag.tags | ||
|
||
|
||
def test_owner_len_greater_than_five(dag_bag: DagBag) -> None: | ||
"""Owner should be defined for each DAG and be longer than 5 characters.""" | ||
for _, dag in dag_bag.dags.items(): | ||
assert len(dag.owner) > 5 | ||
|
||
|
||
def test_desc_len_greater_than_fifteen(dag_bag: DagBag) -> None: | ||
"""Description should be defined for each DAG and be longer than 30 characters.""" | ||
for _, dag in dag_bag.dags.items(): | ||
if isinstance(dag.description, str): | ||
assert len(dag.description) > 30 | ||
|
||
|
||
def test_owner_not_airflow(dag_bag: DagBag) -> None: | ||
"""Owner should not be 'airflow'.""" | ||
for _, dag in dag_bag.dags.items(): | ||
assert str.lower(dag.owner) != "airflow" | ||
|
||
|
||
def test_three_or_less_retries(dag_bag: DagBag) -> None: | ||
"""Retries should be 3 or less.""" | ||
for _, dag in dag_bag.dags.items(): | ||
assert dag.default_args["retries"] <= 3 |