enhancing autogenerated api tests to generate appropriate fields.
Change-Id: Ie0468d0ff6df392b0c999e1447d9fb4fc4d6aa2a
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 3c394dc..4b769c9 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -288,6 +288,12 @@
return random.randint(1,10000)
if value == 'float':
return random.uniform(1,10)
+ if value == 'role':
+ return random.choice(['admin', 'pi', 'tech', 'billing'])
+ if value == 'direction':
+ return random.choice(['in', 'out'])
+ if value == 'flavor':
+ return random.choice(['m1.large', 'm1.medium', 'm1.small'])
else:
return None
diff --git a/src/test/cord-api/Tests/targets/xosapitests.xtarget b/src/test/cord-api/Tests/targets/xosapitests.xtarget
index 1f0efad..958310e 100644
--- a/src/test/cord-api/Tests/targets/xosapitests.xtarget
+++ b/src/test/cord-api/Tests/targets/xosapitests.xtarget
@@ -100,6 +100,18 @@
{% if f.link -%}
${tmp_{{ f.options.model | lower }}_id}= Create {{ f.options.model }}
${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }}_id ${tmp_{{ f.options.model | lower }}_id}
+ {% elif f.name == "created" or f.name == "amend" or f.name =="expires" or f.name =='granted' -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value float
+ ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}"
+ {% elif f.name == "role" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value role
+ ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}"
+ {% elif f.name == "direction" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value direction
+ ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}"
+ {% elif f.name == "flavor" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value flavor
+ ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}"
{% else -%}
${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value {{ f.type }}
${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}"
@@ -164,6 +176,15 @@
{% if f.name == "created" or f.name == "amend" or f.name =="expires" or f.name =='granted' -%}
${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value float
${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}"
+ {% elif f.name == "role" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value role
+ ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}"
+ {% elif f.name == "direction" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value direction
+ ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}"
+ {% elif f.name == "flavor" -%}
+ ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value flavor
+ ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}"
{% else -%}
${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value {{ f.type }}
${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}"
@@ -177,30 +198,10 @@
${json_{{ m.name | lower}}_login_base_tmp}= Set Variable testloginbase
${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /login_base "${json_{{ m.name | lower }}_login_base_tmp}"
{% endif %}
- {% if m.name == "SiteRole" -%}
- ${json_{{ m.name | lower}}_role_tmp}= Set Variable admin
- ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /role "${json_{{ m.name | lower }}_role_tmp}"
- {% endif %}
- {% if m.name == "SliceRole" -%}
- ${json_{{ m.name | lower}}_role_tmp}= Set Variable admin
- ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /role "${json_{{ m.name | lower }}_role_tmp}"
- {% endif %}
- {% if m.name == "ControllerRole" -%}
- ${json_{{ m.name | lower}}_role_tmp}= Set Variable admin
- ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /role "${json_{{ m.name | lower }}_role_tmp}"
- {% endif %}
{% if m.name == "Slice" -%}
${json_{{ m.name | lower}}_name}= Generate Random Slice Name
${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /name "${json_{{ m.name | lower }}_name}"
{% endif -%}
- {% if m.name == "InterfaceType" -%}
- ${json_{{ m.name | lower}}_direction}= Set Variable in
- ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /direction "${json_{{ m.name | lower }}_direction}"
- {% endif -%}
- {% if m.name == "Flavor" -%}
- ${json_{{ m.name | lower}}_flavor}= Set Variable m1.large
- ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /flavor "${json_{{ m.name | lower }}_flavor}"
- {% endif -%}
{% if m.name == "Network" -%}
${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /permit_all_slices true
{% endif %}