Skip to content

Commit

Permalink
updated doc.py to only show table defined exports (#936)
Browse files Browse the repository at this point in the history
* updated doc.py to only show table defined exports

* updated test for table exports

* black fix
  • Loading branch information
barrydaniels-nl authored Feb 4, 2025
1 parent ed42927 commit ff9f1b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dso_api/dynamic_api/views/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _table_context(ds: Dataset, table: DatasetTableSchema):
filters = _get_filters(table.fields)
exports = []
# if dataset_name in settings.EXPORTED_DATASETS.split(","):
if ds.enable_export:
if ds.tables.get(name=table_name).enable_export:
export_info = []
for type_, extension in (
("csv", "csv"),
Expand Down
17 changes: 11 additions & 6 deletions src/tests/test_dynamic_api/test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ def test_dataset(api_client, filled_router, gebieden_dataset):


@pytest.mark.django_db
def test_dataset_for_export_links(api_client, filled_router, gebieden_dataset):
def test_table_for_export_links(api_client, filled_router, gebieden_dataset):
"""Tests documentation for a single dataset."""
gebieden_dataset.enable_export = True
gebieden_dataset.save()
table = gebieden_dataset.tables.get(name="bouwblokken")
table.enable_export = True
table.save()
gebieden_doc = reverse(
"dynamic_api:doc-gebieden"
) # Gebieden has relationships between its tables.
Expand All @@ -73,9 +74,13 @@ def test_dataset_for_export_links(api_client, filled_router, gebieden_dataset):
content = response.rendered_content
# Extensions for exported format followed by ".zip"
# are signalling links to the generated exports.
assert "gpkg.zip" in content
assert "jsonl.zip" in content
assert "csv.zip" in content
assert "gebieden_bouwblokken.gpkg.zip" in content
assert "gebieden_bouwblokken.jsonl.zip" in content
assert "gebieden_bouwblokken.csv.zip" in content

assert "gebieden_buurten.csv.zip" not in content
assert "gebieden_buurten.jsonl.zip" not in content
assert "gebieden_buurten.gpkg.zip" not in content


@pytest.mark.django_db
Expand Down

0 comments on commit ff9f1b8

Please sign in to comment.