From: David Lutterkort lutter@redhat.com
--- server/features/hardware_profiles.feature | 23 +++++++++++ .../step_definitions/hardware_profiles_steps.rb | 41 ++++++++++++++++++++ server/features/support/mock/config.yaml | 5 ++- 3 files changed, 68 insertions(+), 1 deletions(-) create mode 100644 server/features/hardware_profiles.feature create mode 100644 server/features/step_definitions/hardware_profiles_steps.rb
diff --git a/server/features/hardware_profiles.feature b/server/features/hardware_profiles.feature new file mode 100644 index 0000000..9c1de72 --- /dev/null +++ b/server/features/hardware_profiles.feature @@ -0,0 +1,23 @@ +Feature: Working with hardware profiles + In order to work with hardware profiles + + Background: + Given I want to get XML + + Scenario: I want to get list of all hardware profiles + When I follow hardware profiles link in entry points + Then I should see <HARDWARE_PROFILE_COUNT> hardware profile inside hardware profiles + And each link in hardware profiles should point me to valid hardware profile + + Scenario: I want to show hardware profile details + When I request for '<HARDWARE_PROFILE_ID>' hardware profile + Then I should get this hardware profile + And it should have a href attribute + And hardware profile should include id parameter + And it should have a fixed property 'cpu' + And it should have a range property 'memory' + And it should have a enum property 'storage' + + Scenario: I want filter hardware profiles by architecture + When I want hardware profiles with '<HARDWARE_PROFILE_ARCH>' architecture + Then the returned hardware profiles should have architecture '<HARDWARE_PROFILE_ARCH>' diff --git a/server/features/step_definitions/hardware_profiles_steps.rb b/server/features/step_definitions/hardware_profiles_steps.rb new file mode 100644 index 0000000..b2e64bf --- /dev/null +++ b/server/features/step_definitions/hardware_profiles_steps.rb @@ -0,0 +1,41 @@ +Then /^it should have a (\w+) attribute$/ do |name| + attr = Nokogiri::XML(last_response.body).xpath('/hardware-profile').first[name] + attr.should_not be_nil + if (name == 'href') + attr.should == "http://example.org/api/hardware_profiles/#%7BCONFIG%5B:hardware_profile_id%5..." + end +end + +Then /^it should have a (\w+) property '(.+)'$/ do |kind, name| + props = Nokogiri::XML(last_response.body).xpath("/hardware-profile/property[@name = '#{name}']") + props.size.should == 1 + prop = props.first + prop['kind'].should == kind + prop['unit'].should_not be_nil + if kind == 'range' + ranges = prop.xpath('range') + ranges.size.should == 1 + range = ranges.first + range['first'].should_not be_nil + range['last'].should_not be_nil + end + if kind == 'enum' + enums = prop.xpath('enum') + enums.size.should == 1 + enums.first.xpath('entry').size.should_not == 0 + end +end + +Then /^the returned hardware profiles should have (.+) '(.+)'$/ do |parameter, value| + params = {} + value = replace_variables(value) + @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] } + get '/api/hardware_profiles', params, {} + last_response.status.should == 200 + parameters = [] + Nokogiri::XML(last_response.body).xpath("/hardware-profiles/hardware-profile/property[@name = '#{parameter}']").each do |elt| + parameters << elt['value'] + end + parameters.uniq.size.should == 1 + parameters.uniq.first.should == value +end diff --git a/server/features/support/mock/config.yaml b/server/features/support/mock/config.yaml index 6b76f08..4ec0d03 100644 --- a/server/features/support/mock/config.yaml +++ b/server/features/support/mock/config.yaml @@ -1,4 +1,4 @@ ---- +--- :username: mockuser :password: mockpassword :storage_snapshot_id: snap2 @@ -19,7 +19,10 @@ :image_id: img2 :storage_volume_state: AVAILABLE :flavor_id: m1-small +:hardware_profile_id: m1-large :instance_realm: us :image_count: 3 :storage_volume_count: 2 :flavor_count: 5 +:hardware_profile_count: 4 +:hardware_profile_arch: x86_64