def test_clone_action_obj_too_many_args(fx_get_sub_parser): """ Test scenario when more than 2 args are provided and no prefix is specified for cloning an exception is raised """ # Get sub_parser object, its dest is cmd cmd_clone = CmdClone(fx_get_sub_parser) expected_error = "Did not receive the right amount of object names. Only expect 2 and 3 were given. Only specify the original action object name and a new object name" with pytest.raises(SDKException) as excinfo: export_data = cmd_clone._clone_action_object( ("thing1", "thing2", "thing3"), TEST_EXPORT, 'Fuction', ResilientObjMap.FUNCTIONS, 'functions', CmdClone.replace_function_object_attrs) # Gather the message from the execution info, throwing away the other args exception_message, = excinfo.value.args assert exception_message == expected_error
def test_clone_action_obj_failure(fx_get_sub_parser, input_args, obj_type, obj_identifier, obj_name, replace_fn): """ Parametrized tests to confirm for each scenario if a non-existant action object is provided an appropriate exception is raised with the expected message """ # Get sub_parser object, its dest is cmd cmd_clone = CmdClone(fx_get_sub_parser) expected_error = "{}: '{}' not found in this export.".format( obj_type, input_args[0]) with pytest.raises(SDKException) as excinfo: export_data = cmd_clone._clone_action_object( input_args, TEST_EXPORT, obj_type, obj_identifier, obj_name, replace_fn) # Gather the message from the execution info, throwing away the other args exception_message, = excinfo.value.args assert expected_error in exception_message