From 240058f13abed471c8cfc1cdb0517319950f4e10 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:07:49 +0200 Subject: [PATCH 1/3] feat: rename license name to license title BREAKING CHANGE: Renames a field in the /datasets response model --- oc4ids_datastore_api/models.py | 2 +- oc4ids_datastore_api/schemas.py | 2 +- oc4ids_datastore_api/services.py | 5 ++++- tests/test_services.py | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/oc4ids_datastore_api/models.py b/oc4ids_datastore_api/models.py index 1386b74..0272589 100644 --- a/oc4ids_datastore_api/models.py +++ b/oc4ids_datastore_api/models.py @@ -10,7 +10,7 @@ class DatasetSQLModel(SQLModel, table=True): source_url: str publisher_name: str license_url: str | None - license_name: str | None + license_title: str | None json_url: str | None csv_url: str | None xlsx_url: str | None diff --git a/oc4ids_datastore_api/schemas.py b/oc4ids_datastore_api/schemas.py index 0486d12..95de789 100644 --- a/oc4ids_datastore_api/schemas.py +++ b/oc4ids_datastore_api/schemas.py @@ -9,7 +9,7 @@ class Publisher(BaseModel): class License(BaseModel): url: str | None - name: str | None + title: str | None class Download(BaseModel): diff --git a/oc4ids_datastore_api/services.py b/oc4ids_datastore_api/services.py index 76a96e0..1026899 100644 --- a/oc4ids_datastore_api/services.py +++ b/oc4ids_datastore_api/services.py @@ -16,7 +16,10 @@ def _transform_dataset(dataset: DatasetSQLModel) -> Dataset: loaded_at=dataset.updated_at, source_url=dataset.source_url, publisher=Publisher(name=dataset.publisher_name), - license=License(url=dataset.license_url, name=dataset.license_name), + license=License( + url=dataset.license_url, + title=dataset.license_title, + ), downloads=downloads, ) diff --git a/tests/test_services.py b/tests/test_services.py index 4e290e6..96b21f7 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -17,7 +17,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None: source_url="https://test-dataset.json", publisher_name="test_publisher", license_url="https://license.com", - license_name="License", + license_title="License", json_url="https://downloads/test_dataset.json", csv_url="https://downloads/test_dataset.csv", xlsx_url="https://downloads/test_dataset.xlsx", @@ -31,7 +31,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None: loaded_at=now, source_url="https://test-dataset.json", publisher=Publisher(name="test_publisher"), - license=License(name="License", url="https://license.com"), + license=License(title="License", url="https://license.com"), downloads=[ Download(format="json", url="https://downloads/test_dataset.json"), Download(format="csv", url="https://downloads/test_dataset.csv"), @@ -51,7 +51,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non source_url="https://test-dataset.json", publisher_name="test_publisher", license_url="https://license.com", - license_name="License", + license_title="License", json_url="https://downloads/test_dataset.json", csv_url=None, xlsx_url=None, @@ -65,7 +65,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non loaded_at=now, source_url="https://test-dataset.json", publisher=Publisher(name="test_publisher"), - license=License(name="License", url="https://license.com"), + license=License(title="License", url="https://license.com"), downloads=[ Download(format="json", url="https://downloads/test_dataset.json"), ], From 52b51cb23b37b97c4d45e10b7930802ca8936366 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:08:50 +0200 Subject: [PATCH 2/3] feat: add short titles for licenses --- oc4ids_datastore_api/models.py | 1 + oc4ids_datastore_api/schemas.py | 1 + oc4ids_datastore_api/services.py | 1 + tests/test_services.py | 6 ++++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/oc4ids_datastore_api/models.py b/oc4ids_datastore_api/models.py index 0272589..6362a25 100644 --- a/oc4ids_datastore_api/models.py +++ b/oc4ids_datastore_api/models.py @@ -11,6 +11,7 @@ class DatasetSQLModel(SQLModel, table=True): publisher_name: str license_url: str | None license_title: str | None + license_title_short: str | None json_url: str | None csv_url: str | None xlsx_url: str | None diff --git a/oc4ids_datastore_api/schemas.py b/oc4ids_datastore_api/schemas.py index 95de789..f3c6193 100644 --- a/oc4ids_datastore_api/schemas.py +++ b/oc4ids_datastore_api/schemas.py @@ -10,6 +10,7 @@ class Publisher(BaseModel): class License(BaseModel): url: str | None title: str | None + title_short: str | None class Download(BaseModel): diff --git a/oc4ids_datastore_api/services.py b/oc4ids_datastore_api/services.py index 1026899..48f5b1a 100644 --- a/oc4ids_datastore_api/services.py +++ b/oc4ids_datastore_api/services.py @@ -19,6 +19,7 @@ def _transform_dataset(dataset: DatasetSQLModel) -> Dataset: license=License( url=dataset.license_url, title=dataset.license_title, + title_short=dataset.license_title_short, ), downloads=downloads, ) diff --git a/tests/test_services.py b/tests/test_services.py index 96b21f7..3be18ea 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -18,6 +18,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None: publisher_name="test_publisher", license_url="https://license.com", license_title="License", + license_title_short="L", json_url="https://downloads/test_dataset.json", csv_url="https://downloads/test_dataset.csv", xlsx_url="https://downloads/test_dataset.xlsx", @@ -31,7 +32,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None: loaded_at=now, source_url="https://test-dataset.json", publisher=Publisher(name="test_publisher"), - license=License(title="License", url="https://license.com"), + license=License(title="License", title_short="L", url="https://license.com"), downloads=[ Download(format="json", url="https://downloads/test_dataset.json"), Download(format="csv", url="https://downloads/test_dataset.csv"), @@ -52,6 +53,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non publisher_name="test_publisher", license_url="https://license.com", license_title="License", + license_title_short="L", json_url="https://downloads/test_dataset.json", csv_url=None, xlsx_url=None, @@ -65,7 +67,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non loaded_at=now, source_url="https://test-dataset.json", publisher=Publisher(name="test_publisher"), - license=License(title="License", url="https://license.com"), + license=License(title="License", title_short="L", url="https://license.com"), downloads=[ Download(format="json", url="https://downloads/test_dataset.json"), ], From feac1cdd2524d58ae45e598a5c52162528b84289 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 25 Feb 2025 16:09:02 +0200 Subject: [PATCH 3/3] feat: bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8e174ea..fca949c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi" [project] name = "oc4ids-datastore-api" description = "OC4IDS Datastore API" -version = "0.1.0" +version = "0.2.0" readme = "README.md" dependencies = [ "fastapi[standard]",