Skip to content

Commit

Permalink
Clean up with Bernhard
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Oct 3, 2023
1 parent 83a2b6f commit 7025cbc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 54 deletions.
20 changes: 10 additions & 10 deletions openatlas/api/resources/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion openatlas/views/entity_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
99 changes: 56 additions & 43 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 7025cbc

Please sign in to comment.