Added API cases for Analytics Service

Signed-off-by: anil-tegala <anil.tegala@candelatech.com>
This commit is contained in:
anil-tegala
2022-06-29 01:19:55 +05:30
parent 042595e7fa
commit a69e58bf15
2 changed files with 103 additions and 15 deletions

View File

@@ -763,19 +763,20 @@ class AnalyticUtils:
return resp
def get_board_data_bytime(self, board_id, from_date, to_date):
uri = self.sdk_client.build_url_analytics("/board/" + board_id + "timepoints/?fromdate=" +from_date+ "&" +to_date)
uri = self.sdk_client.build_url_analytics("/board/" + board_id + "timepoints/?fromdate=" +from_date+ "&endDate=" +to_date)
print(uri)
resp = requests.get(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100)
self.sdk_client.check_response("GET", resp, self.sdk_client.make_headers(), "", uri)
return resp
def delete_board_data_bytime(self, board_id, from_date, to_date):
uri = self.sdk_client.build_url_analytics("/board/" + board_id + "timepoints/?fromdate=" +from_date+ "&" +to_date)
uri = self.sdk_client.build_url_analytics("/board/" + board_id + "timepoints/?fromdate=" +from_date+ "&endDate" +to_date)
print(uri)
resp = requests.delete(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100)
self.sdk_client.check_response("DELETE", resp, self.sdk_client.make_headers(), "", uri)
return resp
# need to test this method
def get_country_code_for_ip(self, ip_list):
uri = self.sdk_client.build_url_analytics("/iptocountry?iplist=" +ip_list)
print(uri)
@@ -783,14 +784,14 @@ class AnalyticUtils:
self.sdk_client.check_response("GET", resp, self.sdk_client.make_headers(), "", uri)
return resp
def get_wificlients_history(self, venue):
uri = self.sdk_client.build_url_analytics("/wifiClientHistory?macsOnly=true" +venue)
def get_wificlients_history(self, venue_id):
uri = self.sdk_client.build_url_analytics("/wifiClientHistory?macsOnly=true" +venue_id)
print(uri)
resp = requests.get(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100)
self.sdk_client.check_response("GET", resp, self.sdk_client.make_headers(), "", uri)
return resp
def get_wifi_client_history(self, venue, client_mac):
def get_wifi_client_history(self, client_mac):
uri = self.sdk_client.build_url_analytics("/wifiClientHistory/"+client_mac+"?orderSpec=true")
print(uri)
resp = requests.get(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100)
@@ -820,6 +821,7 @@ class AnalyticUtils:
self.sdk_client.check_response("POST", resp, self.sdk_client.make_headers(), payload, uri)
return resp
class UProfileUtility:
def __init__(self, sdk_client=None, controller_data=None):
@@ -1181,9 +1183,9 @@ if __name__ == '__main__':
'password': 'OpenWifi%123',
}
obj = Controller(controller_data=controller)
print('get devices:\n')
obj.get_devices()
obj_ana = AnalyticUtils(sdk_client=obj)
print('GET Boards API \n ', obj_ana.get_boards())
print('GET Board by ID API \n ', obj_ana.get_board_by_id('c5d273cd-a025-4107-ae11-0dd8160a3bb0'))
# obj_ana.get_boards()
# obj_ana.get_board_by_id(board_id='005ddb54-246b-41a7-b004-d0318f7b8633')
# up = UProfileUtility(sdk_client=obj, controller_data=controller)

View File

@@ -12,11 +12,11 @@ import json
import allure
# @pytest.mark.ow_sanity_lf
# @pytest.mark.uc_sanity
# @pytest.mark.owa_api_tests
# @allure.feature("SDK ANALYTICS REST API")
class TestUcentralAnalyticsisionService(object):
@pytest.mark.ow_sanity_lf
@pytest.mark.uc_sanity
@pytest.mark.owa_api_tests
@allure.feature("SDK ANALYTICS REST API")
class TestUcentralAnalyticsService(object):
@pytest.mark.owa_get_boards
def test_analytics_service_boards(self, setup_owan_controller):
@@ -121,12 +121,98 @@ class TestUcentralAnalyticsisionService(object):
resp = setup_owan_controller.get_board_by_id(board_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Analytics edited board-verify", body=body)
allure.attach(name="Verify GET Board", body=body)
if resp.status_code != 200:
assert False
resp = setup_owan_controller.delete_board(board_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Analytics created board-delete", body=body)
allure.attach(name="Verify DELETE board", body=body)
if resp.status_code != 200:
assert False
assert False
@pytest.mark.owa_get_board_devices
def test_analytics_service_get_board_devices(self, setup_owan_controller):
"""
Test Retrieved Devices from the Board
"""
resp=setup_owan_controller.get_board_devices()
print(resp.json())
allure.attach(name="Verify Devices Retrieved from the Board", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_get_board_data_bytime
def test_analytics_service_get_board_data_bytime(self, setup_owan_controller):
"""
Test Retrieving of Board Data from timestamp
"""
resp=setup_owan_controller.get_board_data_bytime(board_id='', from_date=1656433571, to_date=1656437971)
print(resp.json())
allure.attach(name="Verify GET Board Data Retrieved as per time period ", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_delete_board_data_bytime
def test_analytics_service_get_board_data_bytime(self, setup_owan_controller):
"""
Test Retrieving of Board Data from timestamp
"""
resp=setup_owan_controller.delete_board_data_bytime(board_id='', from_date=1656433571, to_date=1656437971)
print(resp.json())
allure.attach(name="Verify DELETE Board Data as per time period ", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_get_wificlients_history
def test_analytics_service_get_wificlients_history(self, setup_owan_controller):
"""
Test Retrieving of Wifi Clients from a Venue
"""
resp=setup_owan_controller.get_wificlients_history(venue_id="")
print(resp.json())
allure.attach(name="Verify GET Wifi clients from the Venue ", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_get_wifi_client_history
def test_analytics_service_get_wifi_client_history(self, setup_owan_controller):
"""
Test Retrieveing a Wifi Client from a Venue
"""
resp=setup_owan_controller.get_wifi_client_history(client_mac="")
print(resp.json())
allure.attach(name="Verify GET Wifi clients from the Venue ", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_delete_wifi_client_history
def test_analytics_service_delete_wifi_client_history(self, setup_owan_controller):
"""
Test Removing of a Wifi Client from a Venue
"""
resp=setup_owan_controller.delete_wifi_client_history(client_mac="")
print(resp.json())
allure.attach(name="Verify DELETE a Wifi client from the Venue ", body=str(resp.json()),
attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.owa_get_system_info
def test_analytics_service_get_system_info(self, setup_owan_controller):
"""
Test System Command
"""
system_info=setup_owan_controller.get_system_info(command="info")
print(system_info.json())
allure.attach(name="system info", body=str(system_info.json()), attachment_type=allure.attachment_type.JSON)
assert system_info.status_code == 200
@pytest.mark.owa_post_system_info
def test_analytics_service_post_system_info(self, setup_owan_controller):
"""
Test System command
"""
system_info=setup_owan_controller.post_system_info(command="getsubsystemnames")
print(system_info.json())
allure.attach(name="Verify a system command: getsubsystemnames", body=str(system_info.json()), attachment_type=allure.attachment_type.JSON)
assert system_info.status_code == 200