def execute(self) -> None: """Create instance using MSB K8S plugin.""" super().execute() self.instance = Instance.create( cloud_region_id=settings.CLOUD_REGION_ID, profile_name=settings.PNF_PROFILE_NAME, rb_name=settings.PNF_RB_NAME, rb_version=settings.PNF_RB_VERSION)
def test_instance_delete(): instance = Instance.get_by_id(pytest.INSTANCE_ID) instance.delete()
def test_instance_get_all(): instances = list(Instance.get_all())
def test_instance_create(): definition = Definition.get_definition_by_name_version(RB_NAME, RB_VERSION) profile = definition.get_profile_by_name(PROFILE_NAME) instance = Instance.create(CLOUD_REGION_ID, profile.profile_name, definition.rb_name, definition.rb_version) pytest.INSTANCE_ID = instance.instance_id
def test_instance_get_by_id(mock_send_message, mock_send_message_json): mock_send_message_json.return_value = INSTANCE instance = Instance.get_by_id("ID_GENERATED_BY_K8SPLUGIN") assert instance.instance_id == "ID_GENERATED_BY_K8SPLUGIN" assert instance.namespace == "NAMESPACE_WHERE_INSTANCE_HAS_BEEN_DEPLOYED_AS_DERIVED_FROM_PROFILE" instance.delete()
def test_instance_create(mock_send_message_json): mock_send_message_json.return_value = INSTANCE instance = Instance.create("test_cloud_region_id", "test_profile_name", "test_rb_name", "test_rb_version") assert instance.instance_id == "ID_GENERATED_BY_K8SPLUGIN" assert instance.namespace == "NAMESPACE_WHERE_INSTANCE_HAS_BEEN_DEPLOYED_AS_DERIVED_FROM_PROFILE"
def test_instance_get_all(mock_send_message_json): mock_send_message_json.return_value = [] assert len(list(Instance.get_all())) == 0 mock_send_message_json.return_value = INSTANCES assert len(list(Instance.get_all())) == 1