Skip to content

Commit 0295673

Browse files
Merge pull request #6 from OpenDataServices/short-license-titles
Add short titles for licenses
2 parents 95da0da + feac1cd commit 0295673

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

oc4ids_datastore_api/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class DatasetSQLModel(SQLModel, table=True):
1010
source_url: str
1111
publisher_name: str
1212
license_url: str | None
13-
license_name: str | None
13+
license_title: str | None
14+
license_title_short: str | None
1415
json_url: str | None
1516
csv_url: str | None
1617
xlsx_url: str | None

oc4ids_datastore_api/schemas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class Publisher(BaseModel):
99

1010
class License(BaseModel):
1111
url: str | None
12-
name: str | None
12+
title: str | None
13+
title_short: str | None
1314

1415

1516
class Download(BaseModel):

oc4ids_datastore_api/services.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ def _transform_dataset(dataset: DatasetSQLModel) -> Dataset:
1616
loaded_at=dataset.updated_at,
1717
source_url=dataset.source_url,
1818
publisher=Publisher(name=dataset.publisher_name),
19-
license=License(url=dataset.license_url, name=dataset.license_name),
19+
license=License(
20+
url=dataset.license_url,
21+
title=dataset.license_title,
22+
title_short=dataset.license_title_short,
23+
),
2024
downloads=downloads,
2125
)
2226

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
55
[project]
66
name = "oc4ids-datastore-api"
77
description = "OC4IDS Datastore API"
8-
version = "0.1.0"
8+
version = "0.2.0"
99
readme = "README.md"
1010
dependencies = [
1111
"fastapi[standard]",

tests/test_services.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def test_get_all_datasets(mocker: MockerFixture) -> None:
1717
source_url="https://test-dataset.json",
1818
publisher_name="test_publisher",
1919
license_url="https://license.com",
20-
license_name="License",
20+
license_title="License",
21+
license_title_short="L",
2122
json_url="https://downloads/test_dataset.json",
2223
csv_url="https://downloads/test_dataset.csv",
2324
xlsx_url="https://downloads/test_dataset.xlsx",
@@ -31,7 +32,7 @@ def test_get_all_datasets(mocker: MockerFixture) -> None:
3132
loaded_at=now,
3233
source_url="https://test-dataset.json",
3334
publisher=Publisher(name="test_publisher"),
34-
license=License(name="License", url="https://license.com"),
35+
license=License(title="License", title_short="L", url="https://license.com"),
3536
downloads=[
3637
Download(format="json", url="https://downloads/test_dataset.json"),
3738
Download(format="csv", url="https://downloads/test_dataset.csv"),
@@ -51,7 +52,8 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non
5152
source_url="https://test-dataset.json",
5253
publisher_name="test_publisher",
5354
license_url="https://license.com",
54-
license_name="License",
55+
license_title="License",
56+
license_title_short="L",
5557
json_url="https://downloads/test_dataset.json",
5658
csv_url=None,
5759
xlsx_url=None,
@@ -65,7 +67,7 @@ def test_get_all_datasets_missing_download_formats(mocker: MockerFixture) -> Non
6567
loaded_at=now,
6668
source_url="https://test-dataset.json",
6769
publisher=Publisher(name="test_publisher"),
68-
license=License(name="License", url="https://license.com"),
70+
license=License(title="License", title_short="L", url="https://license.com"),
6971
downloads=[
7072
Download(format="json", url="https://downloads/test_dataset.json"),
7173
],

0 commit comments

Comments
 (0)