Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose publisher countries #9

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oc4ids_datastore_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DatasetSQLModel(SQLModel, table=True):
dataset_id: str = Field(primary_key=True)
source_url: str
publisher_name: str
publisher_country: str | None
license_url: str | None
license_title: str | None
license_title_short: str | None
Expand Down
1 change: 1 addition & 0 deletions oc4ids_datastore_api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class Publisher(BaseModel):
name: str
country: str | None


class License(BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion oc4ids_datastore_api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def _transform_dataset(dataset: DatasetSQLModel) -> Dataset:
return Dataset(
loaded_at=dataset.updated_at,
source_url=dataset.source_url,
publisher=Publisher(name=dataset.publisher_name),
publisher=Publisher(
name=dataset.publisher_name, country=dataset.publisher_country
),
license=License(
url=dataset.license_url,
title=dataset.license_title,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
[project]
name = "oc4ids-datastore-api"
description = "OC4IDS Datastore API"
version = "0.2.0"
version = "0.3.0"
readme = "README.md"
dependencies = [
"fastapi[standard]",
Expand Down
5 changes: 3 additions & 2 deletions tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None:
dataset_id="test_dataset",
source_url="https://test-dataset.json",
publisher_name="test_publisher",
publisher_country="ab",
license_url="https://license.com",
license_title="License",
license_title_short="L",
Expand All @@ -31,7 +32,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None:
expected_dataset = Dataset(
loaded_at=now,
source_url="https://test-dataset.json",
publisher=Publisher(name="test_publisher"),
publisher=Publisher(name="test_publisher", country="ab"),
license=License(title="License", title_short="L", url="https://license.com"),
downloads=[
Download(format="json", url="https://downloads/test_dataset.json"),
Expand Down Expand Up @@ -66,7 +67,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non
expected_dataset = Dataset(
loaded_at=now,
source_url="https://test-dataset.json",
publisher=Publisher(name="test_publisher"),
publisher=Publisher(name="test_publisher", country=None),
license=License(title="License", title_short="L", url="https://license.com"),
downloads=[
Download(format="json", url="https://downloads/test_dataset.json"),
Expand Down