Add Model-Updation Smoke Tests 15/15215/1 master
authorAshish Jain <jain.ashish@samsung.com>
Mon, 10 Nov 2025 13:19:09 +0000 (13:19 +0000)
committerashishj1729 <jain.ashish@samsung.com>
Mon, 10 Nov 2025 14:08:00 +0000 (19:38 +0530)
    The tests added are as follows:
    1. Registers the models, verifies it retrieval, then updates it and
       verfiy if retrieval provides the updated-model
    2. Verfies if correct message and code is responded when the model which
       is not present is updated.

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

index b02604c..33aab70 100644 (file)
@@ -114,7 +114,6 @@ def test_registered_model_deletion():
     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"
     
@@ -127,3 +126,68 @@ def test_registered_model_deletion_when_model_not_present():
     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}"
+
+def test_registered_model_updation():
+    '''
+        The following test verifies how model-updatation happens.
+        The steps include registering the model, retrieving it, updating it, and then attempting to retrieve it again, which should return updated-modelinfo.
+    '''
+    # Submit the Model-registraion job
+    modelName = "test-model-updataion"
+    modelVersion = "10001"
+    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"
+    
+    # Update Model
+    updation_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    update_payload = {
+        "id": model_id, # Needs to be same
+        "modelId": {
+            "modelName": modelName, # Needs to be same
+            "modelVersion" : modelVersion, # Needs to be same
+            'artifactVersion': ''
+        },
+        "description": "new-hello world",
+        "modelInformation": {
+            "metadata": {
+                "author": "new-someone",
+                "owner": ''
+            },
+            "inputDataType": "new-pdcpBytesDl,pdcpBytesUl",
+            "outputDataType": "new-c, d",
+            "targetEnvironment": [
+                {
+                    "platformName": "abc",
+                    "environmentType": "env",
+                    "dependencyList": "a,b,c"
+                }
+            ]
+        },
+        "modelLocation": ''
+    }
+    
+    r = requests.put(url=updation_url, json=update_payload)
+    assert r.status_code == 200, f"Model Updation by id didn't returned 200, but returned {r.status_code}"
+    
+    # Verify Model-Updataion
+    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 (after updation) didn't returned 200, but returned {r.status_code}"
+    assert response_dict == update_payload, f"payload retrieved doesn't match with the updated one\nRetrived: {response_dict}\nExpected : {update_payload}"
+    
+def test_registered_model_updation_when_model_not_present():
+    '''
+        The following test verifies how model-updation happens when the model is not registered/present
+    '''
+    model_id = "invalid"
+    # Update Model 
+    updation_url = f"{BASE_URL}/ai-ml-model-registration/v1/model-registrations/{model_id}"
+    r = requests.put(url=updation_url, json={})
+    assert r.status_code == 404, f"Model Updation by id didn't returned 404, but returned {r.status_code}"
\ No newline at end of file