dump-things-service/dump_things_service/tests/test_paths.py
Christian Monch 60d6085ce4
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 37s
Codespell / Check for spelling errors (push) Successful in 41s
Ruff / Code linting (pull_request) Successful in 50s
Ruff / Code linting (push) Successful in 50s
Type annotation (PR) / check (pull_request) Successful in 1m20s
Test execution / Test-all (push) Successful in 1m26s
chore: apply standard formatting
2026-07-15 12:48:19 +02:00

55 lines
1.8 KiB
Python

from pathlib import (
Path,
PurePosixPath,
)
from dump_things_service import HTTP_406_NOT_ACCEPTABLE
from dump_things_service.collection_endpoints import CollectionRequest
# Path to a local simple test schema
test_schema_location = str((Path(__file__).parent / 'testschema.yaml').absolute())
test_curated_path_collection_name = 'test_curated_path_collection'
test_curated_path_collection_request = CollectionRequest(
name=test_curated_path_collection_name,
default_token='test_default_token',
curated=PurePosixPath('..'),
schema=test_schema_location,
)
test_incoming_path_collection_name = 'test_incoming_path_collection'
test_incoming_path_collection_request = CollectionRequest(
name=test_incoming_path_collection_name,
default_token='test_default_token',
curated=PurePosixPath('curated/'),
schema=test_schema_location,
incoming=PurePosixPath('..'),
)
def test_curated_path(fastapi_client_simple):
test_client, _, admin_token = fastapi_client_simple
# Try to add a collection with an illegal curated path
response = test_client.post(
'/collections',
headers={'x-dumpthings-token': admin_token},
json=test_curated_path_collection_request.model_dump(
mode='json', by_alias=True
),
)
assert response.status_code == HTTP_406_NOT_ACCEPTABLE
def test_incoming_path(fastapi_client_simple):
test_client, _, admin_token = fastapi_client_simple
# Try to add a collection with an illegal curated path
response = test_client.post(
'/collections',
headers={'x-dumpthings-token': admin_token},
json=test_incoming_path_collection_request.model_dump(
mode='json', by_alias=True
),
)
assert response.status_code == HTTP_406_NOT_ACCEPTABLE