Skip to content

Commit

Permalink
add a test to hit empty searches
Browse files Browse the repository at this point in the history
  • Loading branch information
InnocentBug committed Mar 11, 2024
1 parent 006b047 commit 0419bad
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/api/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ def test_api_search_uuid(cript_api: cript.API, dynamic_material_data) -> None:
assert str(uuid_list[0].uuid) == dynamic_material_data["uuid"]


@pytest.mark.skipif(not HAS_INTEGRATION_TESTS_ENABLED, reason="requires a real cript_api_token")
def test_empty_paginator(cript_api: cript.API) -> None:
non_existent_name = "This is an nonsensical name for a material and should never exist. %^&*()_"
exact_name_paginator = cript_api.search(node_type=cript.Material, search_mode=cript.SearchModes.EXACT_NAME, value_to_search=non_existent_name)
with pytest.raises(StopIteration):
next(exact_name_paginator)
exact_name_paginator.auto_load_nodes = False
with pytest.raises(StopIteration):
next(exact_name_paginator)

# Special 0 UUID should not exist
uuid_paginator = cript_api.search(node_type=cript.Material, search_mode=cript.SearchModes.UUID, value_to_search="00000000-0000-0000-0000-000000000000")
with pytest.raises(StopIteration):
next(uuid_paginator)
exact_name_paginator.auto_load_nodes = False
with pytest.raises(StopIteration):
next(uuid_paginator)


@pytest.mark.skipif(not HAS_INTEGRATION_TESTS_ENABLED, reason="requires a real cript_api_token")
def test_api_search_bigsmiles(cript_api: cript.API) -> None:
"""
Expand Down

0 comments on commit 0419bad

Please sign in to comment.