Wifi 7859 (#516)

* Added Contact Related testcases of Prov UI

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added Prov UI contact related test cases

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added Prov UI contact related function for support

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Changed the test case function names

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>
This commit is contained in:
Haricharan Jaka
2022-05-10 13:48:09 +05:30
committed by GitHub
parent 0608b4aefa
commit 07c6e4d78a
2 changed files with 132 additions and 2 deletions

View File

@@ -401,6 +401,47 @@ class ProvUtils(ConfigureController):
self.check_response("PUT", resp, self.make_headers(), payload, uri)
return resp
def get_contact(self):
uri = self.build_url_prov("contact")
print(uri)
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
def get_contact_by_id(self, contact_id):
uri = self.build_url_prov("contact/" + contact_id)
print(uri)
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
def add_contact(self, payload):
uri = self.build_url_prov("contact/1")
print(uri)
print(payload)
payload = json.dumps(payload)
resp = requests.post(uri, data=payload, headers=self.make_headers(), verify=False, timeout=100)
print(resp)
self.check_response("POST", resp, self.make_headers(), payload, uri)
return resp
def delete_contact(self, contact_id):
uri = self.build_url_prov("contact/" + contact_id)
print(uri)
resp = requests.delete(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("DELETE", resp, self.make_headers(), "", uri)
return resp
def edit_contact(self, payload, contact_id):
uri = self.build_url_prov("contact/" + contact_id)
print(uri)
print(payload)
payload = json.dumps(payload)
resp = requests.put(uri, data=payload, headers=self.make_headers(), verify=False, timeout=100)
print(resp)
self.check_response("PUT", resp, self.make_headers(), payload, uri)
return resp
class UProfileUtility:
def __init__(self, sdk_client=None, controller_data=None):

View File

@@ -31,7 +31,7 @@ class TestUcentralProvisionService(object):
assert resp.status_code == 200
@pytest.mark.prov_api_test
def test_prov_service_create_inventory_device(self, setup_prov_controller, testbed):
def test_prov_service_create_edit_delete_inventory_device(self, setup_prov_controller, testbed):
"""
Test the create device in provision Inventory
"""
@@ -115,7 +115,7 @@ class TestUcentralProvisionService(object):
assert system_info.status_code == 200
@pytest.mark.prov_api_entity_test
def test_prov_service_create_entity(self, setup_prov_controller, testbed):
def test_prov_service_create_edit_delete_entity(self, setup_prov_controller, testbed):
"""
Test the create Entity in provision Inventory
"""
@@ -181,3 +181,92 @@ class TestUcentralProvisionService(object):
allure.attach(name="Entities", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
# Contact related Test cases
@pytest.mark.prov_api_contact
def test_get_contacts(self, setup_prov_controller):
resp = setup_prov_controller.get_contact()
print(resp.json())
allure.attach(name="Contacts", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.prov_api_contact_test
def test_prov_service_create_edit_delete_contact(self, setup_prov_controller, testbed):
"""
Test the create Contact in provision Inventory
"""
payload = {
"name": "Prov-Testing-through-Automation",
"type": "USER",
"title": "Testing_contact",
"salutation": "",
"firstname": "ProvTesting",
"lastname": "Through Automation",
"initials": "",
"visual": "",
"phones": [],
"mobiles": [],
"primaryEmail": "tip@ucentral.com",
"secondaryEmail": "",
"accessPIN": "",
"description": "",
"initialNote": "",
"entity": "0000-0000-0000",
"notes": [{"note": ""}]
}
print(json.dumps(payload))
resp = setup_prov_controller.add_contact(payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact", body=body)
if resp.status_code != 200:
assert False
contact = json.loads(resp.text)
print(contact)
contact_id = contact['id']
resp = setup_prov_controller.get_contact_by_id(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact-verify", body=body)
if resp.status_code != 200:
assert False
# This to edit Entity
editing_payload = {
"accessPIN": "",
"description": "",
"entity": "0000-0000-0000",
"firstname": "ProvTesting",
"initials": "",
"lastname": "Through Automation",
"mobiles": [],
"name": "Prov-Testing-Automation API's",
"notes": [],
"phones": [],
"primaryEmail": "tip@ucentral.com",
"salutation": "",
"secondaryEmail": "",
"title": "Testing_contact",
"type": "USER"
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_contact(editing_payload, contact_id)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
resp = setup_prov_controller.get_contact_by_id(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_contact(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov created contact-delete", body=body)
if resp.status_code != 200:
assert False