updating testservice api tests

Change-Id: Iddae0adecb461ef7f30e68a86a0c48c75b4bb709
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 153ef72..6fa9bfe 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -279,13 +279,13 @@
             dnames.append(names.copy())
         return dnames
 
-    def generate_random_value(self, value):
+    def generate_random_value(self, value, max_length=10, min_int=1, max_int=10000):
         if value == 'string':
-                return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
+                return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(max_length))
         if value == 'bool':
                 return random.choice([True, False])
         if value == 'int32' or value == 'uint32':
-                return random.randint(1,10000)
+                return random.randint(min_int,max_int)
         if value == 'float':
             return random.uniform(1,10)
         if value == 'role':
@@ -296,9 +296,11 @@
             return random.choice(['m1.large', 'm1.medium', 'm1.small'])
         if value == 'vlan_tag':
             return random.choice(['555', '1-4096', 'ANY'])
+        if value == 'ip_address':
+            return ".".join(str(random.randint(0, 255)) for _ in range(4))
         else:
             return None
 
     def generate_random_slice_name(self):
         random_name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
-        return 'testloginbase' + random_name
\ No newline at end of file
+        return 'testloginbase' + random_name
diff --git a/src/test/cord-api/Tests/xos-test-service/test-service.robot b/src/test/cord-api/Tests/xos-test-service/test-service.robot
index 013ead4..220c4b4 100644
--- a/src/test/cord-api/Tests/xos-test-service/test-service.robot
+++ b/src/test/cord-api/Tests/xos-test-service/test-service.robot
@@ -1,3 +1,4 @@
+
 # XOS Core Test
 #
 # This test will validate the xos-core's sync steps and model policies using the TestService
@@ -32,17 +33,62 @@
     ${resp}=    CORD Post    ${testservice_si}     ${data}
     ${json_content}=    To Json    ${resp.content}
     ${test_serviceinstance_id}=    Get From Dictionary    ${json_content}    id
+    ${default_float}=    Get From Dictionary    ${json_content}    optional_float_with_default
+    ${default_string}=    Get From Dictionary    ${json_content}    optional_string_with_default
+    ${default_int}=    Get From Dictionary    ${json_content}    optional_int_with_default
     Set Suite Variable    ${test_serviceinstance_id}
     Set Suite Variable    ${model_name}
+    Set Suite Variable    ${default_float}
+    Set Suite Variable    ${default_string}
+    Set Suite Variable    ${default_int}
     Repeat Keyword    10s    Validate Duplicate Model    false
 
-Update Model with Duplicate
-    [Tags]    update
+Replicate Model with Duplicate
+    [Tags]    replicate
     CORD Put    ${testservice_si}     {'create_duplicate': ${true}}    ${test_serviceinstance_id}
-    Wait Until Keyword Succeeds    60s    2s    Validate Duplicate Model    true
+    Wait Until Keyword Succeeds    15s    2s    Validate Duplicate Model    true
+
+Update Model Values and Validate on Duplicate
+    [Tags]    update
+    ##create optional strings
+    @{choices}=    Create List    one    two
+    ${optional_string}=    Generate Random Value    string    max_length=50
+    ${optional_string_choice}=    Evaluate    random.choice($choices)    random
+    ${optional_string_max_length}=    Generate Random Value    string    max_length=32
+    ${optional_string_date}=    Get Current Date    result_format=%m-%d-%Y
+    ${optional_string_ip}=    Generate Random Value    ip_address
+    ##create optional ints
+    @{choices}=    Create List    one    two
+    ${optional_integer_min}=    Generate Random Value    int32    min_int=100
+    ${optional_integer_max}=    Generate Random Value    int32    max_int=199
+    ${optional_string_choice}=    Evaluate    random.choice($choices)    random
+    ${optional_string_max_length}=    Generate Random Value    string    max_length=32
+    #${optional_string_max}=    Get Substring    ${optional_string_max_length}    0    32
+    ${optional_string_date}=    Get Current Date    result_format=%m-%d-%Y
+    ${optional_string_ip}=    Generate Random Value    ip_address
+    ##create optional float
+    ${optional_float}=    Generate Random Value    float
+    Set Suite Variable    ${optional_string}
+    Set Suite Variable    ${optional_string_choice}
+    Set Suite Variable    ${optional_string_max_length}
+    Set Suite Variable    ${optional_string_date}
+    Set Suite Variable    ${optional_string_ip}
+    Set Suite Variable    ${optional_integer_min}
+    Set Suite Variable    ${optional_integer_max}
+    Set Suite Variable    ${optional_float}
+    ${data}=    Create Dictionary    optional_string=${optional_string}
+    Set To Dictionary    ${data}    optional_string_with_choices=${optional_string_choice}
+    Set To Dictionary    ${data}    optional_string_max_length=${optional_string_max_length}
+    #Set To Dictionary    ${data}    optional_string_date=${optional_string_date}
+    Set To Dictionary    ${data}    optional_string_ip=${optional_string_ip}
+    Set To Dictionary    ${data}    optional_int_with_min=${optional_integer_min}
+    Set To Dictionary    ${data}    optional_int_with_max=${optional_integer_max}
+    Set To Dictionary    ${data}    optional_float=${optional_float}
+    CORD Put    ${testservice_si}    ${data}    ${test_serviceinstance_id}
+    Wait Until Keyword Succeeds    60s    2s    Validate Duplicate Model with Updates
 
 Revert Model
-    [Tags]    revert    notready
+    [Tags]    revert
     CORD Put    ${testservice_si}     {'create_duplicate': ${false}}    ${test_serviceinstance_id}
     Wait Until Keyword Succeeds    60s    2s    Validate Duplicate Model    false
 
@@ -73,3 +119,23 @@
     [Arguments]    ${data}
     ${dict}=    Get From List    ${data['items']}    0
     Should Be Equal As Strings    ${dict['name']}    ${model_name}
+    Should Be Equal As Strings    ${dict['optional_float_with_default']}    ${default_float}
+    Should Be Equal As Strings    ${dict['optional_string_with_default']}    ${default_string}
+    Should Be Equal As Strings    ${dict['optional_int_with_default']}    ${default_int}
+
+Validate Duplicate Model with Updates
+    ${resp}=    CORD Get    ${testservice_duplicate_si}
+    ${jsondata}=    To Json    ${resp.content}
+    ${dict}=    Get From List    ${jsondata['items']}    0
+    Should Be Equal As Strings    ${dict['name']}    ${model_name}
+    Should Be Equal As Strings    ${dict['optional_float_with_default']}    ${default_float}
+    Should Be Equal As Strings    ${dict['optional_string_with_default']}    ${default_string}
+    Should Be Equal As Strings    ${dict['optional_int_with_default']}    ${default_int}
+    Should Be Equal As Strings    ${dict['optional_string']}    ${optional_string}
+    Should Be Equal As Strings    ${dict['optional_string_with_choices']}    ${optional_string_choice}
+    Should Be Equal As Strings    ${dict['optional_string_max_length']}    ${optional_string_max_length}
+    Should Be Equal As Strings    ${dict['optional_string_ip']}    ${optional_string_ip}
+    Should Be Equal As Strings    ${dict['optional_int_with_min']}    ${optional_integer_min}
+    Should Be Equal As Strings    ${dict['optional_int_with_max']}    ${optional_integer_max}
+    ${float_diff}=    Evaluate    abs(${optional_float} - ${dict['optional_float']})
+    Should Be True    ${float_diff} < .0005