From da415f0eedcac4f225d88f072131d9e438989622 Mon Sep 17 00:00:00 2001 From: Kalyan Date: Fri, 3 Nov 2023 04:55:03 +0530 Subject: [PATCH] reordering ml_commons tests : moved test_search to the end (#330) * move test-search to the end Signed-off-by: kalyan * fix lint Signed-off-by: kalyan --------- Signed-off-by: kalyan --- tests/ml_commons/test_ml_commons_client.py | 191 ++++++++++----------- 1 file changed, 94 insertions(+), 97 deletions(-) diff --git a/tests/ml_commons/test_ml_commons_client.py b/tests/ml_commons/test_ml_commons_client.py index 10be2c164..9452d6097 100644 --- a/tests/ml_commons/test_ml_commons_client.py +++ b/tests/ml_commons/test_ml_commons_client.py @@ -100,102 +100,6 @@ def test_execute(): ), "Raised Exception during execute API testing with JSON string" -def test_search(): - # Search task cases - raised = False - try: - search_task_obj = ml_client.search_task( - input_json='{"query": {"match_all": {}},"size": 1}' - ) - assert search_task_obj["hits"]["hits"] != [] - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching task" - - raised = False - try: - search_task_obj = ml_client.search_task( - input_json={"query": {"match_all": {}}, "size": 1} - ) - assert search_task_obj["hits"]["hits"] != [] - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching task" - - raised = False - try: - search_task_obj = ml_client.search_task(input_json=15) - assert search_task_obj == "Invalid JSON object passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching task" - - raised = False - try: - search_task_obj = ml_client.search_task(input_json="15") - assert search_task_obj == "Invalid JSON object passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching task" - - raised = False - try: - search_task_obj = ml_client.search_task( - input_json='{"query": {"match_all": {}},size: 1}' - ) - assert search_task_obj == "Invalid JSON string passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching task" - - # Search model cases - raised = False - try: - search_model_obj = ml_client.search_model( - input_json='{"query": {"match_all": {}},"size": 1}' - ) - assert search_model_obj["hits"]["hits"] != [] - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching model" - - raised = False - try: - search_model_obj = ml_client.search_model( - input_json={"query": {"match_all": {}}, "size": 1} - ) - assert search_model_obj["hits"]["hits"] != [] - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching model" - - raised = False - try: - search_model_obj = ml_client.search_model(input_json=15) - assert search_model_obj == "Invalid JSON object passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching model" - - raised = False - try: - search_model_obj = ml_client.search_model(input_json="15") - assert search_model_obj == "Invalid JSON object passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching model" - - raised = False - try: - search_model_obj = ml_client.search_model( - input_json='{"query": {"match_all": {}},size: 1}' - ) - assert search_model_obj == "Invalid JSON string passed as argument." - except: # noqa: E722 - raised = True - assert raised == False, "Raised Exception in searching model" - - def test_DEPRECATED_integration_pretrained_model_upload_unload_delete(): raised = False try: @@ -515,4 +419,97 @@ def test_integration_model_train_register_full_cycle(): assert raised == False, "Raised Exception in deleting model" -test_integration_model_train_register_full_cycle() +def test_search(): + # Search task cases + raised = False + try: + search_task_obj = ml_client.search_task( + input_json='{"query": {"match_all": {}},"size": 1}' + ) + assert search_task_obj["hits"]["hits"] != [] + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching task" + + raised = False + try: + search_task_obj = ml_client.search_task( + input_json={"query": {"match_all": {}}, "size": 1} + ) + assert search_task_obj["hits"]["hits"] != [] + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching task" + + raised = False + try: + search_task_obj = ml_client.search_task(input_json=15) + assert search_task_obj == "Invalid JSON object passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching task" + + raised = False + try: + search_task_obj = ml_client.search_task(input_json="15") + assert search_task_obj == "Invalid JSON object passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching task" + + raised = False + try: + search_task_obj = ml_client.search_task( + input_json='{"query": {"match_all": {}},size: 1}' + ) + assert search_task_obj == "Invalid JSON string passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching task" + + # Search model cases + raised = False + try: + search_model_obj = ml_client.search_model( + input_json='{"query": {"match_all": {}},"size": 1}' + ) + assert search_model_obj["hits"]["hits"] != [] + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching model" + + raised = False + try: + search_model_obj = ml_client.search_model( + input_json={"query": {"match_all": {}}, "size": 1} + ) + assert search_model_obj["hits"]["hits"] != [] + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching model" + + raised = False + try: + search_model_obj = ml_client.search_model(input_json=15) + assert search_model_obj == "Invalid JSON object passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching model" + + raised = False + try: + search_model_obj = ml_client.search_model(input_json="15") + assert search_model_obj == "Invalid JSON object passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching model" + + raised = False + try: + search_model_obj = ml_client.search_model( + input_json='{"query": {"match_all": {}},size: 1}' + ) + assert search_model_obj == "Invalid JSON string passed as argument." + except: # noqa: E722 + raised = True + assert raised == False, "Raised Exception in searching model"