def generic_lcs_pass(self, owner_service, resource_label, resource_id, lc_event, lc_state): """ execute an lcs event and verify that it passes and affects state @param owner_service instance of service client that will handle the request @param resource_label string like "instrument_device" @param resource_id string @param lc_event string like LCE.INTEGRATE @param lc_state string like LCS.INTEGRATED (where the state should end up """ lcsmethod = getattr(owner_service, "execute_%s_lifecycle" % resource_label) readmethod = getattr(owner_service, "read_%s" % resource_label) lcsmethod(resource_id, lc_event) resource_obj = readmethod(resource_id) parts = get_maturity_visibility(resource_obj.lcstate) self.assertEqual(lc_state, parts[0])
def _resource_lcstate_in(self, resource_obj, permissible_states=[]): parts = get_maturity_visibility(resource_obj.lcstate) return self._make_result(parts[0] in permissible_states, "'%s' resource is in state '%s', wanted [%s]" % (self._get_resource_type(resource_obj), parts[0], str(permissible_states)))
def _resource_lcstate_in(self, resource_obj, permissible_states=None): assert(type("") != type(resource_obj)) if permissible_states is None: permissible_states = [] parts = get_maturity_visibility(resource_obj.lcstate) return self._make_result(parts[0] in permissible_states, "'%s' resource is in state '%s', wanted [%s]" % (resource_obj._get_type(), parts[0], str(permissible_states)))
def base_policy_exception(self, fail_fn): log.info("Create platform agent") platform_agent_obj = any_old(RT.PlatformAgent) platform_agent_id = self.client.IMS.create_platform_agent(platform_agent_obj) log.debug("executing lifecycle transition to PLANNED") self.client.IMS.execute_platform_agent_lifecycle(platform_agent_id, LCE.PLAN) log.debug("reading current revision") resource_obj = self.client.IMS.read_platform_agent(platform_agent_id) log.debug("checking current state of resource") self.assertEqual(LCS.PLANNED, get_maturity_visibility(resource_obj.lcstate)[0]) log.debug("executing test-specific failure check") fail_fn(platform_agent_id, LCE.DEVELOP)
def _resource_lcstate_in(self, resource_obj, permissible_states=[]): parts = get_maturity_visibility(resource_obj.lcstate) return parts[0] in permissible_states