Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent attribute names inside Automate Engine #13440

Merged
merged 3 commits into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def process_args_array(args, args_key)
# process Array::servers => MiqServer::2,MiqServer::3,MiqServer::4
key = args_key.split(CLASS_SEPARATOR).last
value = args.delete(args_key)
args[key] = load_array_objects_from_string(value)
args[key.downcase] = load_array_objects_from_string(value)
end

def process_args_attribute(args, args_key)
Expand All @@ -273,7 +273,7 @@ def process_args_attribute(args, args_key)
key, klass = get_key_name_and_klass_from_key(args_key)
value = args.delete(args_key)
args["#{key}_id"] = value unless @attributes.key?(key)
args[key] = MiqAeObject.convert_value_based_on_datatype(value, klass)
args[key.downcase] = MiqAeObject.convert_value_based_on_datatype(value, klass)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkanoor The key is already lower case here.

else
args[args_key.downcase] = args.delete(args_key) if args_key != args_key.downcase
end
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/miq_automation_engine/miq_ae_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ def value_match(value, xml_value)
expect(result["vms"].length).to eq(1)
end

it "#process_args_as_attributes with mixed types and case insensitive" do
result = @miq_obj.process_args_as_attributes("Array::VMs" => "VmOrTemplate::#{@vm.id}",
"Name" => "fred")
expect(result["vms"]).to be_kind_of(Array)
expect(result["vms"].length).to eq(1)
expect(result["name"]).to eq("fred")
expect(result["Name"]).to be_nil
expect(result["VMs"]).to be_nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but can you move this check for VMs next to the vms tests so they are grouped together. Makes it clearer what you are testing.

end

it "#process_args_as_attributes with an array" do
vm2 = FactoryGirl.create(:vm_vmware)
result = @miq_obj.process_args_as_attributes({"Array::vms" => "VmOrTemplate::#{@vm.id},VmOrTemplate::#{vm2.id}"})
Expand Down