Skip to content

Commit

Permalink
Drop NULL technical_source from filter choices (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Jun 30, 2022
1 parent 4c54f34 commit 199afcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion server/infrastructure/datasets/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ async def get_service_set(self) -> Set[str]:

async def get_technical_source_set(self) -> Set[str]:
async with self._db.session() as session:
stmt = select(DatasetModel.technical_source.distinct())
stmt = select(DatasetModel.technical_source.distinct()).where(
DatasetModel.technical_source.is_not(None)
)
result = await session.execute(stmt)
return set(result.scalars())

Expand Down
12 changes: 10 additions & 2 deletions tests/api/test_datasets_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ async def test_dataset_filters_info(

await bus.execute(
CreateDatasetFactory.build(
service="Example service",
service="Same example service",
technical_source="Example database system",
)
)

# Add another with filterable optional fields left out
await bus.execute(
CreateDatasetFactory.build(
service="Same example service",
technical_source=None,
)
)

response = await client.get("/datasets/filters/", auth=temp_user.auth)
assert response.status_code == 200

Expand All @@ -53,7 +61,7 @@ async def test_dataset_filters_info(
]

assert data["service"] == [
"Example service",
"Same example service",
]

assert sorted(data["format"]) == [
Expand Down

0 comments on commit 199afcb

Please sign in to comment.