def deep_load(self) -> None: """Deep load Object informations from SDC.""" url = (f"{self.base_front_url}/sdc1/feProxy/rest/v1/" "screen?excludeTypes=VFCMT&excludeTypes=Configuration") headers = headers_sdc_creator(SdcResource.headers) if self.status == const.UNDER_CERTIFICATION: headers = headers_sdc_tester(SdcResource.headers) response = self.send_message_json("GET", "Deep Load {}".format( type(self).__name__), url, headers=headers) for resource in response[self._sdc_path()]: if resource["invariantUUID"] == self.unique_uuid: if resource["uuid"] == self.identifier: self._logger.debug("Resource %s found in %s list", resource["name"], self._sdc_path()) self.unique_identifier = resource["uniqueId"] self._category_name = resource["categories"][0]["name"] subcategories = resource["categories"][0].get( "subcategories", [{}]) self._subcategory_name = None if subcategories is None else \ subcategories[0].get("name") return if self._sdc_path() == "services": for dependency in self.send_message_json( "GET", "Get service dependecies", f"{self._base_create_url()}/services/" f"{resource['uniqueId']}/" "dependencies"): if dependency["version"] == self.version: self.unique_identifier = dependency["uniqueId"] return
def test__deep_load_response_OK_under_cert(mock_send, mock_created): mock_created.return_value = True vf = Vf() vf.identifier = "5689" vf._version = "4567" vf._status = const.UNDER_CERTIFICATION mock_send.return_value = { 'resources': [{ 'uuid': '5689', 'name': 'test', 'uniqueId': '71011', 'categories': [{ 'name': 'test', 'subcategories': [{ 'name': 'test_subcategory' }] }] }] } vf.deep_load() assert vf.unique_identifier == "71011" assert vf._category_name == "test" assert vf._subcategory_name == "test_subcategory" mock_send.assert_called_once_with( 'GET', 'Deep Load Vf', "{}/sdc1/feProxy/rest/v1/screen?excludeTypes=VFCMT&excludeTypes=Configuration" .format(vf.base_front_url), headers=headers_sdc_tester(vf.headers))
def deep_load(self) -> None: """Deep load Object informations from SDC.""" url = ( f"{self.base_front_url}/sdc1/feProxy/rest/v1/" "screen?excludeTypes=VFCMT&excludeTypes=Configuration" ) headers = headers_sdc_creator(SdcResource.headers) if self.status == const.UNDER_CERTIFICATION: headers = headers_sdc_tester(SdcResource.headers) response = self.send_message_json("GET", "Deep Load {}".format( type(self).__name__), url, headers=headers) if response: for resource in response[self._sdc_path()]: if resource["uuid"] == self.identifier: self._logger.debug("Resource %s found in %s list", resource["name"], self._sdc_path()) self.unique_identifier = resource["uniqueId"]
def test_headers_sdc_tester(): base_header = {} sdc_headers_tester = headers_sdc_tester(base_header) assert base_header != sdc_headers_tester assert sdc_headers_tester["USER_ID"] == "jm0007" assert sdc_headers_tester["Authorization"]