def test_check_policies_none(mock_send_message_json): mock_send_message_json.return_value = POLICIES exists = Clamp.check_policies(policy_name="Test") mock_send_message_json.\ assert_called_once_with('GET', 'Get stocked policies', (f"{Clamp.base_url()}/policyToscaModels/")) assert not exists
def test_Clamp_requirements(): """Integration tests for Clamp.""" requests.get("{}/reset".format(Clamp._base_url)) # no add resource in clamp # svc already exists in mock clamp Clamp(cert=('LICENSE', '')) svc = Service(name="service01") template_exists = Clamp.check_loop_template(service=svc) assert template_exists policy_exists = Clamp.check_policies(policy_name="MinMax", req_policies=2) assert policy_exists
def check(self, operational_policies: list, is_template: bool = False) -> str: """Check CLAMP requirements to create a loop.""" self._logger.info("Check operational policy") for policy in operational_policies: exist = Clamp.check_policies(policy_name=policy["name"], req_policies=30) # 30 required policy self._logger.info("Operational policy found.") if not exist: raise ValueError("Couldn't load the policy %s", policy) # retrieve the service..based on service name service: Service = Service(self.service_name) if is_template: loop_template = Clamp.check_loop_template(service=service) self._logger.info("Loop template checked.") return loop_template