Add Model-Deletion Smoke Tests 14/15214/1
authorAshish Jain <jain.ashish@samsung.com>
Mon, 10 Nov 2025 12:45:12 +0000 (12:45 +0000)
committerashishj1729 <jain.ashish@samsung.com>
Mon, 10 Nov 2025 13:36:34 +0000 (19:06 +0530)
The tests added are as follows:
1. Registers the models, verifies it retrieval, then deletes it and
   verfiy if retrieval says "model not found"
2. Verfies if correct message and code is responded when the model which
   is not present is deleted.

Issue-Id: AIMLFW-310
Change-Id: I837ce717b9082ff695f443224bf580e80889f891
Signed-off-by: ashishj1729 <jain.ashish@samsung.com>
component-testing/tests/test_component.py

index e183d9b..b02604c 100644 (file)
@@ -86,3 +86,44 @@ def test_job_status_retrieval_when_job_not_present():
     assert r.status_code == 500, f"Model Retrieval by id (when id not present) didn't returned 500, but returned {r.status_code}"
     assert response_dict.get("message") == expected_message, "message(in response) submitted and retrieved doesn't match"
 
+
+def test_registered_model_deletion():
+    '''
+        The following test verifies how model-deletion happens when the model is already registered/present.
+        The steps include registering the model, retrieving it, deleting it, and then attempting to retrieve it again, which should return an appropriate response.
+    '''
+    # Submit the Model-registraion job
+    modelName = "test-model-deletion"
+    modelVersion = "10006"
+    model_id = submit_model_registration(modelName, modelVersion)
+    
+    # Check job Status through id
+    retrieval_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    r = requests.get(url=retrieval_url)
+    response_dict = r.json()
+    assert r.status_code == 200, f"Model Retrieval by id didn't returned 200, but returned {r.status_code}"
+    assert response_dict.get("id") == model_id, "model_id submitted and retrieved doesn't match"
+    
+    # Delete Model
+    deletion_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    r = requests.delete(url=deletion_url)
+    assert r.status_code == 204, f"Model Deletion by id didn't returned 204, but returned {r.status_code}"
+    
+    # Check job Status through id (It should not be present)
+    retrieval_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    expected_message = "record not found"
+    r = requests.get(url=retrieval_url)
+    response_dict = r.json()
+    response_dict = r.json()
+    assert r.status_code == 500, f"Model Retrieval by id (after deletion) didn't returned 500, but returned {r.status_code}"
+    assert response_dict.get("message") == expected_message, "message(in response) submitted and retrieved doesn't match"
+    
+def test_registered_model_deletion_when_model_not_present():
+    '''
+        The following test verifies how model-deleltion happens when the model is not registered/present
+    '''
+    model_id = "invalid"
+    # Delete Model 
+    deletion_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    r = requests.delete(url=deletion_url)
+    assert r.status_code == 204, f"Model Deletion by id didn't returned 204, but returned {r.status_code}"