From 0419bad6a16100014e26e200094b4f1dba6ec7e9 Mon Sep 17 00:00:00 2001 From: Ludwig Schneider Date: Mon, 11 Mar 2024 12:46:07 -0500 Subject: [PATCH] add a test to hit empty searches --- tests/api/test_search.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/api/test_search.py b/tests/api/test_search.py index 9381d8ee..d09c08bf 100644 --- a/tests/api/test_search.py +++ b/tests/api/test_search.py @@ -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: """