diff --git a/openatlas/api/resources/util.py b/openatlas/api/resources/util.py index f11aa114d..0bd0f7d2c 100644 --- a/openatlas/api/resources/util.py +++ b/openatlas/api/resources/util.py @@ -166,16 +166,16 @@ def get_reference_systems( links_inverse: list[Link]) -> list[dict[str, Any]]: ref = [] for link_ in links_inverse: - if not isinstance(link_.domain, ReferenceSystem) or not link_.type: - continue - system = g.reference_systems[link_.domain.id] - ref.append({ - 'referenceURL': system.website_url, - 'id': link_.description, - 'resolverURL': system.resolver_url, - 'identifier': f"{system.resolver_url or ''}{link_.description}", - 'type': to_camel_case(g.types[link_.type.id].name), - 'referenceSystem': system.name}) + if isinstance(link_.domain, ReferenceSystem) and link_.type: + system = g.reference_systems[link_.domain.id] + ref.append({ + 'referenceURL': system.website_url, + 'id': link_.description, + 'resolverURL': system.resolver_url, + 'identifier': + f"{system.resolver_url or ''}{link_.description}", + 'type': to_camel_case(g.types[link_.type.id].name), + 'referenceSystem': system.name}) return ref diff --git a/openatlas/views/entity_index.py b/openatlas/views/entity_index.py index f61bca8f2..6ca2cf84f 100644 --- a/openatlas/views/entity_index.py +++ b/openatlas/views/entity_index.py @@ -10,7 +10,7 @@ from openatlas.display.table import Table from openatlas.display.util import ( button, format_date, get_base_table_data, get_file_path, is_authorized, - link, manual, required_group, convert_size) + link, manual, required_group) from openatlas.models.entity import Entity from openatlas.models.gis import Gis diff --git a/tests/test_api.py b/tests/test_api.py index 0e3c208de..6464f7857 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -419,6 +419,8 @@ def test_api(self) -> None: self.app.get( url_for('api_03.type_tree', download=True))]: assert bool(rv.get_json()['typeTree']) + rv = self.app.get(url_for('api_03.type_tree', count=True)) + assert rv.get_json() > 0 for rv in [ self.app.get(url_for( @@ -775,52 +777,62 @@ def test_api(self) -> None: rv = self.app.get(url_for('api_03.subunits', id_=actor.id)) assert 'ID is not a valid place' in rv.get_json()['title'] - rv = self.app.get(url_for( - 'api_03.query', - entities=location.id, - cidoc_classes='E18', - view_classes='artifact', - system_classes='person', - sort='desc', - column='id', - download=True, - last=place.id)) - assert 'ID is last entity' in rv.get_json()['title'] - - for rv in [ - self.app.get(url_for('api_03.query', entities=12345)), - self.app.get(url_for( - 'api_03.cidoc_class', cidoc_class='E68', last=1231)), - self.app.get(url_for( - 'api_03.view_class', - view_class='place', - search='{"typeName":[{"operator":"equal",' - '"values":["Boundary Mark", "Height", "Dimension"],' - '"logicalOperator":"and"}]}')), - self.app.get(url_for( - 'api_03.view_class', - view_class='place', - search='{"beginFrom":[{"operator":"lesserThan",' - '"values":["2000-1-1"],' - '"logicalOperator":"or"}]}')), - - self.app.get(url_for( + rv = self.app.get( + url_for( 'api_03.query', - entities=place.id, + entities=location.id, cidoc_classes='E18', view_classes='artifact', system_classes='person', - format='lp', - search='{"entityDescription":[{"operator":"like",' - '"values":["IS", "sam", "FrOdo"],' - '"logicalOperator":"and"}]}'))]: + sort='desc', + column='id', + download=True, + last=place.id)) + assert 'ID is last entity' in rv.get_json()['title'] + + for rv in [ + self.app.get(url_for('api_03.query', entities=12345)), + self.app.get( + url_for( + 'api_03.cidoc_class', + cidoc_class='E68', + last=1231)), + self.app.get( + url_for( + 'api_03.view_class', + view_class='place', + search= + '{"typeName":[{"operator":"equal",' + '"values":["Boundary Mark", "Height", "Dimension"],' + '"logicalOperator":"and"}]}')), + self.app.get( + url_for( + 'api_03.view_class', + view_class='place', + search= + '{"beginFrom":[{"operator":"lesserThan",' + '"values":["2000-1-1"],' + '"logicalOperator":"or"}]}')), + self.app.get( + url_for( + 'api_03.query', + entities=place.id, + cidoc_classes='E18', + view_classes='artifact', + system_classes='person', + format='lp', + search= + '{"entityDescription":[{"operator":"like",' + '"values":["IS", "sam", "FrOdo"],' + '"logicalOperator":"and"}]}'))]: rv = rv.get_json() assert 'No entity available' in rv['title'] - rv = self.app.get(url_for( - 'api_03.query', - system_classes='person', - type_id=boundary_mark.id)) + rv = self.app.get( + url_for( + 'api_03.query', + system_classes='person', + type_id=boundary_mark.id)) assert 'One entity ID is not a type' in rv.get_json()['title'] rv = self.app.get( @@ -873,10 +885,11 @@ def test_api(self) -> None: '"logicalOperator":"or"}]}')) assert 'Invalid search syntax' in rv.get_json()['title'] - for rv in [ - self.app.get(url_for('api_03.type_entities', id_=1234)), - self.app.get(url_for('api_03.type_entities_all', id_=1234))]: - assert 'Entity is not a type' in rv.get_json()['title'] + rv = self.app.get(url_for('api_03.type_entities', id_=1234)) + assert 'Entity is not a type' in rv.get_json()['title'] + + rv = self.app.get(url_for('api_03.type_entities_all', id_=1234)) + assert 'Entity is not a type' in rv.get_json()['title'] rv = self.app.get(url_for( 'api_03.view_class',