Skip to content

Commit 4526f56

Browse files
committed
test: mirror app/ layout and rebuild the integration test suite
- Move unit tests into app-mirroring sub-packages (storage/, crates/, etc.) and switch pytest to importlib import mode with pythonpath=".". - Rewrite the integration test for the new stack - Update the integration workflow deps Closes #184
1 parent 882fe57 commit 4526f56

18 files changed

Lines changed: 155 additions & 548 deletions

β€Ž.github/workflows/test_docker.ymlβ€Ž

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install pytest requests minio docker
23+
pip install pytest requests boto3
2424
25-
- name: Build Docker Compose Containers
25+
- name: Run integration tests (brings up the compose stack)
2626
run: |
2727
cp example.env .env
28-
docker compose -f docker-compose-develop.yml build
28+
pytest -s -v tests/test_integration.py
2929
30-
- name: Spin Up Docker Compose and Run Tests
31-
run: pytest -s -v tests/test_integration.py
32-
33-
- name: Ensure that Docker Compose is Shutdown
30+
- name: Ensure Docker Compose is shut down
3431
if: always()
35-
run: docker compose down
32+
run: >
33+
docker compose -f docker-compose-develop.yml -p cratey_integration
34+
--profile objectstore down -v || true

β€Žapp/crates/resolver.pyβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def _object_exists(storage: StorageBackend, key: str) -> bool:
4444
return False
4545

4646

47-
def resolve_crate(
48-
storage: StorageBackend, crate_id: str, crate_prefix: str
49-
) -> ResolvedCrate:
47+
def resolve_crate(storage: StorageBackend, crate_id: str, crate_prefix: str) -> ResolvedCrate:
5048
"""Resolve ``crate_id`` to a concrete crate object.
5149
5250
:raises InvalidCrateId: If the ID is malformed.

β€Ždocker-compose-develop.ymlβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ services:
2323
- PROFILES_PATH=/app/profiles
2424
depends_on:
2525
- redis
26+
# Metadata validation runs synchronously in this process, so the flask
27+
# service needs the custom profiles mounted too (not just the worker).
28+
volumes:
29+
- ./tests/data/rocrate_validator_profiles:/app/profiles:ro
2630

2731
celery_worker:
2832
build:

β€Žpyproject.tomlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ dev = [
3737
include = ["app*"]
3838

3939
[tool.pytest.ini_options]
40+
addopts = "--import-mode=importlib"
41+
pythonpath = ["."]
4042
log_format = "%(asctime)s %(levelname)s %(message)s"
4143
log_date_format = "%Y-%m-%d %H:%M:%S"
4244

0 commit comments

Comments
Β (0)