Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion tests/test_restapi_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ def test_search_contributor(session):
es_result = result.json()
assert es_result['totalItems'] > 100 and es_result['totalItems'] < 200

def test_search_contributor_2(session):
# All query terms must match the same agent
query_params = {'_q': 'contributor:(lars andersson)',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
result = session.get(FIND_API,
params=query_params)
assert result.status_code == 200

es_result = result.json()
assert es_result['totalItems'] == 1 # Matching ID: p60wv08128rft37

def test_search_contributor_3(session):
query_params = {'_q': 'contributor:lars contributor:andersson',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
result = session.get(FIND_API,
params=query_params)
assert result.status_code == 200

es_result = result.json()
assert es_result['totalItems'] > 5

def test_search_subject(session):
query_params = {'_q': 'subject:"sao:Arbetsmarknad"',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
Expand Down Expand Up @@ -290,7 +311,7 @@ def test_search_dewey(session):

def test_search_title(session):
# hasTitle + relationship.entity.hasTitle + translationOf.hasTitle
query_params = {'_q': 'titel:(Nonchalans sjabb och dödliga fräknar) titel:(The quality of sprawl) title:(A working forest)',
query_params = {'_q': 'titel:(Nonchalans sjabb och dödliga fräknar) titel:(The quality of sprawl) titel:(A working forest)',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
result = session.get(FIND_API,
params=query_params)
Expand All @@ -299,6 +320,28 @@ def test_search_title(session):
es_result = result.json()
assert es_result['totalItems'] == 1 # Matching ID: vc55czd6447wmv1

def test_search_title_2(session):
# This query should fail since hasTitle is indexed as a nested field in Elasticsearch meaning that all query terms must match the same title
query_params = {'_q': 'titel:(Nonchalans sjabb och dödliga fräknar The quality of sprawl A working forest)',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
result = session.get(FIND_API,
params=query_params)
assert result.status_code == 200

es_result = result.json()
assert es_result['totalItems'] == 0

def test_search_title_3(session):
# hasPart.hasTitle + hasPart.translationOf.hasTitle + seriesMembership.inSeries.instanceOf.hasTitle
query_params = {'_q': 'titel:(I fullmånens sken) titel:(Once upon a bite) titel:(Harlequin lust)',
'_appConfig': json.dumps(DEFAULT_WORK_FILTER)}
result = session.get(FIND_API,
params=query_params)
assert result.status_code == 200

es_result = result.json()
assert es_result['totalItems'] == 1 # Matching ID: vd6792t6174w1z3

def test_search_isxn(session):
# identifiedBy[ISBN].value + identifiedBy[ISSN].value + identifiedBy[ISMN].value
query_params = {'_q': 'isxn:(9789100118969 OR 0002-6204 OR M004211915)',
Expand Down