class CeicConfiguration(object): _DEFAULT_RETURN_TYPE = "application/json" _GET_SERIES_SERIES_ID_LIMIT = 3000 def __init__(self): self._api_client = ApiClient() self._set_default_return_type() @property def api_client(self): return self._api_client @property def downloads_file_url(self): return "https://downloads-stage.ceicdata.com/downloads.json" if \ "api-stage" in self._api_client.configuration.host else \ "https://downloads.ceicdata.com/downloads.json" @property def python_package_url(self): return "https://downloads-stage.ceicdata.com/python" if \ "api-stage" in self._api_client.configuration.host else \ "https://downloads.ceicdata.com/python" @property def get_series_series_id_limit(self): return self._GET_SERIES_SERIES_ID_LIMIT @property def server(self): return self._api_client.configuration.host @server.setter def server(self, value): self._api_client.configuration.host = value def set_token(self, access_token): self._api_client.set_default_header("Authorization", access_token) def unset_token(self): self._api_client.default_headers.pop("Authorization") def set_proxy(self, proxy_url=None, proxy_username=None, proxy_password=None): self._api_client.configuration.set_proxy(proxy_url, proxy_username, proxy_password) def _set_default_return_type(self): self._api_client.set_default_header("Accept", self._DEFAULT_RETURN_TYPE)
def search_by_keyword(func_data): folder_name = func_data[0] config.testcase_id = func_data[2] config.test_description = func_data[4] config.exp_execution_time = str(func_data[5]) filteroption = func_data[6] test_input = func_data[3].replace(";", ",") access_token = config.access_token api_client = ApiClient(header_name="Authorization", header_value=access_token) series_api = SeriesApi(api_client=api_client) keywords = [] keywords.append(test_input) #print keywords series_search_result = series_api.search_series( keyword=", ".join(keywords), status="T,C,B") #series_search_result = series_api.search_series( keyword=", ".join( keywords )) #print series_search_result.to_dict()["data"]["items"] #print series_search_result actual_xml_file = xml_write(folder_name, series_search_result.to_dict()) cmp_result = xml_csv_comp_filter(actual_xml_file, folder_name, test_input, filteroption) if cmp_result == True: config.tc_result = "PASS" #config.tc_remark = "API Results for provided SeriesCode/SRCode is fetched correctly" config.tc_remark = "API Results for provided '" + filteroption + "' is fetched correctly" config.bln_critical_error_found = False config.bln_sucess = True else: config.tc_result = "FAIL" config.tc_remark = "API Results for provided Series Code is not fetched correctly" config.bln_critical_error_found = False config.bln_sucess = True
def get_metadata_pef(func_data): #Get All requied Inputs folder_name = func_data[0] config.testcase_id = func_data[2] test_input = func_data[3] config.test_description = func_data[4] config.exp_execution_time = str(func_data[5]) #Get Access detials from SDK access_token = config.access_token example_series_id = test_input # print example_series_id api_client = ApiClient(header_name="Authorization", header_value=access_token) series_api = SeriesApi(api_client=api_client) test_input = test_input.replace(";", ",") id = test_input.split(",") newseriesid = "" dict = [] p = 0 r = 0 def update_without_overwriting(d, x): dict.update({k: v for k, v in x.items() if k not in d}) # for i in range (len(id)): print id[i] for num in range(1, len(id) + 1): newseriesid = newseriesid + "," + id[r] p += 1 r += 1 if p % 100 == 0: newseriesid = newseriesid[1:] series_metadata_result = series_api.get_series_metadata( id=newseriesid).to_dict() #series_metadata_result = Ceic.series_metadata("407293587").to_dict() dict.append(series_metadata_result) newseriesid = "" p = 0 actual_xml_file = xml_write(folder_name, dict, func_data[2]) #time.sleep( ) cmp_result = xml_csv_comp_new(actual_xml_file, folder_name, test_input, func_data[2]) if cmp_result == "": config.tc_result = "PASS" config.tc_remark = "All Metadata is fetched for a provided series" config.bln_critical_error_found = False config.bln_sucess = True else: config.tc_result = "FAIL" # config.tc_remark = "API Results for provided Series Code is not fetched correctly" config.tc_remark = cmp_result config.bln_critical_error_found = False config.bln_sucess = True
def get_metadata(func_data): # start_time = datetime.now().strftime( "%Y/%m/%d" + " " + "%I:%M:%S %p") folder_name = func_data[0] config.testcase_id = func_data[2] test_input = func_data[3] config.test_description = func_data[4] config.exp_execution_time = str(func_data[5]) test_input = test_input.replace(";", ",") #series_metadata_result = Ceic.series_metadata(test_input) # print(folder_name, test_input) access_token = config.access_token example_series_id = test_input # print example_series_id api_client = ApiClient(header_name="Authorization", header_value=access_token) series_api = SeriesApi(api_client=api_client) series_metadata_result = series_api.get_series_metadata( id=example_series_id) actual_xml_file = xml_write(folder_name, series_metadata_result.to_dict(), func_data[2]) # time.sleep(10) cmp_result = xml_csv_comp_new(actual_xml_file, folder_name, test_input, func_data[2]) # result = [] # for value in range(len(cmp_result)): # if cmp_result[value] == []: # blnflag = True # else: # blnflag = False # result.append(cmp_result[value]) if cmp_result == "": config.tc_result = "PASS" config.tc_remark = "All Metadata is fetched for a provided series" config.bln_critical_error_found = False config.bln_sucess = True else: config.tc_result = "FAIL" # config.tc_remark = "API Results for provided Series Code is not fetched correctly" config.tc_remark = cmp_result config.bln_critical_error_found = False config.bln_sucess = True
def filter_option_by_seriesid(func_data): folder_name = func_data[0] config.testcase_id = func_data[2] config.test_description = func_data[4] config.exp_execution_time = str(func_data[5]) filteroption = func_data[6] test_input = func_data[3].replace(";", ",") access_token = config.access_token example_series_id = test_input api_client = ApiClient(header_name="Authorization", header_value=access_token) series_api = SeriesApi(api_client=api_client) #series_metadata_result = series_api.get_series_metadata( id=example_series_id ) series_result = series_api.get_series(id=example_series_id) #print series_result actual_xml_file = xml_write(folder_name, series_result.to_dict(), func_data[2]) if filteroption == "Timepoint": cmp_result = xml_csv_comp_filter_for_timepoint(actual_xml_file, folder_name, test_input, func_data[2]) else: cmp_result = xml_csv_comp_filter(actual_xml_file, folder_name, test_input, filteroption) if cmp_result == True: config.tc_result = "PASS" #config.tc_remark = "API Results for provided SeriesCode/SRCode is fetched correctly" config.tc_remark = "API Results for provided '" + filteroption + "' series is fetched correctly" config.bln_critical_error_found = False config.bln_sucess = True else: config.tc_result = "FAIL" config.tc_remark = "API Results for provided Series Code is not fetched correctly" config.bln_critical_error_found = False config.bln_sucess = True
from ceic_api_client.api_client import ApiClient from ceic_api_client.apis.dictionary_api import DictionaryApi from ceic_api_client.apis.series_api import SeriesApi from ceic_api_client.apis.insights_api import InsightsApi import dicttoxml import xml.etree.ElementTree as et from openpyxl import load_workbook file = 'C:\\Users\\rchethana\\Documents\\SDK_Automation\\XML-TestData\\Metadata\\insights_details.xlsx' file1 = open("C:\\Users\\rchethana\\Desktop\\notepad_python.txt", "w") wb = load_workbook(file) sheet = wb.get_sheet_by_name('Insights') access_token = "yUmpy171bzDrqPyE6veMScrsp1n7v2Tfa9i6NVG2nBGFqw0vE9Gs0CCud6DNOPUnyTvoYYKuFwS1US8ll6wwyhPRe8F0pqWesHlSiITLcUvQtN1KFP8Osw1Bk1fR5nl8" #example_insight_id = "f8e64f6b-003a-414c-895b-99b7e7dca317" api_client = ApiClient(header_name="Authorization", header_value=access_token) insights_api = InsightsApi(api_client=api_client) for i in range(40, 102): example_insight_id = sheet.cell(row=i, column=2).value insights_result = insights_api.get_insight_series_metadata( id="7839a60b-57be-415b-b35c-7cfc7f3dbd44").to_dict() # print(insights_result) xml_data = dicttoxml.dicttoxml(insights_result, attr_type=False, root=True) file_path = "C:\\Users\\rchethana\\Documents\\SDK_Automation\\XML-ActualData\\Metadata\\insight_details.xml" f = open(file_path, 'w') f.write(xml_data) f.close() series_id_xml = [] tree = et.parse(file_path) root = tree.getroot()
def get_subscribed_series_id(func_data): # Get All requied Inputs folder_name = func_data[0] config.testcase_id = func_data[2] test_input = func_data[3] config.test_description = func_data[4] config.exp_execution_time = str(func_data[5]) # Get Access detials from SDK test_input = test_input.replace(";", ",") access_token = "fdm90EDqQuKlowfkfZH9SwRIGhcE4UiVP8sdRcIbnwIEPyHe3GgoR4P0lNjxRen6sWLEsQFPpCyh0EBNh2nAWzuiJYFE2lsOT5MelyyIQNAsgL2xbETxriKeU1Z5CKkB" example_series_id = test_input # print example_series_id api_client = ApiClient(header_name="Authorization", header_value=access_token) series_api = SeriesApi(api_client=api_client) #featch Metadata details for the subscribed Series Id series_result = series_api.get_series(id=example_series_id) # series_metadata_result = series_api.get_series_metadata( id=example_series_id ) # print series_result actual_xml_file = xml_write(folder_name, series_result.to_dict(), func_data[2]) import xml.etree.ElementTree as et tree = et.parse(actual_xml_file) root = tree.getroot() subscribed = [] unsubscribed = [] test_input = test_input.split(",") # for name in root.findall( ".//item/code"): # unsubscribed.append(name.text) for name in root.findall(".//entity_id"): subscribed.append(name.text) unsubscribed = list(set(test_input) - set(subscribed)) #print unsubscribed result_string = "" result_string_unsubscribed = "" if subscribed == []: result_string = "" result_string_unsubscribed = "" #unsubsription_string else: for x in subscribed: result_string += x + " ," result_string = result_string[:-1] + "------ Are Subscribed Series" for x in unsubscribed: result_string_unsubscribed += x + " ," result_string_unsubscribed = result_string_unsubscribed[:-1] + "------ Are UnSubscribed Series" config.tc_result = "PASS" config.tc_remark = result_string + "\n" + result_string_unsubscribed print(tc_remark) config.bln_critical_error_found = False config.bln_sucess = True
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client
def __init__(self): self._api_client = ApiClient() self._set_default_return_type()