mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-02 03:48:09 +00:00
Update asb_script for better error handling
Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>
This commit is contained in:
@@ -955,7 +955,17 @@ class Controller(ConfigureController):
|
|||||||
payload = json.dumps(payload)
|
payload = json.dumps(payload)
|
||||||
resp = requests.post(uri, data=payload, headers=self.make_headers(), verify=False, timeout=120)
|
resp = requests.post(uri, data=payload, headers=self.make_headers(), verify=False, timeout=120)
|
||||||
logging.info("resp:- " + str(resp))
|
logging.info("resp:- " + str(resp))
|
||||||
resp = resp.json()
|
# Check if response status is OK (200)
|
||||||
|
if resp.status_code != 200:
|
||||||
|
pytest.fail(f"Request to {uri} failed with status code {resp.status_code}: {resp.text}")
|
||||||
|
# Try parsing JSON
|
||||||
|
try:
|
||||||
|
resp = resp.json()
|
||||||
|
except ValueError:
|
||||||
|
pytest.fail(f"Response from {uri} is not valid JSON: {resp.text}")
|
||||||
|
if 'UUID' not in resp:
|
||||||
|
pytest.fail(f"'UUID' not found in response JSON from {uri}: {resp}")
|
||||||
|
|
||||||
resp = resp['UUID']
|
resp = resp['UUID']
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|||||||
@@ -1052,10 +1052,11 @@ class TestUcentralGatewayService(object):
|
|||||||
"deferred": True,
|
"deferred": True,
|
||||||
"uri": ""
|
"uri": ""
|
||||||
}
|
}
|
||||||
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
|
resp = get_target_object.controller_library_object.check_restrictions(device_name)
|
||||||
if not resp:
|
if not resp:
|
||||||
logging.info("AP is in not restricted and we can trigger script")
|
logging.info("AP is in not restricted and we can trigger script")
|
||||||
uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
|
uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
|
||||||
|
logging.info(f"uuid:{uuid}")
|
||||||
resp = get_target_object.controller_library_object.get_file(device_name, uuid)
|
resp = get_target_object.controller_library_object.get_file(device_name, uuid)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
else:
|
else:
|
||||||
@@ -1100,6 +1101,7 @@ class TestUcentralGatewayService(object):
|
|||||||
if resp:
|
if resp:
|
||||||
logging.info("From GW it's confirmed that AP is restricted now")
|
logging.info("From GW it's confirmed that AP is restricted now")
|
||||||
uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
|
uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
|
||||||
|
logging.info(f"uuid:{uuid}")
|
||||||
resp = get_target_object.controller_library_object.get_file(device_name, uuid)
|
resp = get_target_object.controller_library_object.get_file(device_name, uuid)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user