From: mtaylor <[email protected]>
---
src/features/pool.feature | 63 +++++++++++++++++++++++++++
src/features/step_definitions/pool_steps.rb | 50 +++++++++++++++++++++
src/features/support/env.rb | 8 +++
src/features/support/paths.rb | 11 +++++
src/spec/factories/cloud_account.rb | 5 ++
src/spec/factories/hardware_profile.rb | 7 +++
src/spec/factories/image.rb | 6 +++
src/spec/factories/provider.rb | 4 +-
src/spec/factories/realm.rb | 1 +
9 files changed, 154 insertions(+), 1 deletions(-)
create mode 100644 src/features/pool.feature
create mode 100644 src/features/step_definitions/pool_steps.rb
create mode 100644 src/spec/factories/cloud_account.rb
create mode 100644 src/spec/factories/image.rb
diff --git a/src/features/pool.feature b/src/features/pool.feature
new file mode 100644
index 0000000..c96c2a9
--- /dev/null
+++ b/src/features/pool.feature
@@ -0,0 +1,63 @@
+Feature: Manage Pools
+ In order to manage my cloud infrastructure
+ As a user
+ I want to manage my pools
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+
+ Scenario: Create a new Pool
+ Given I am on the homepage
+ And there is not a pool named "mockpool"
+ When I follow "Add a pool"
+ Then I should be on the new pool page
+ And I should see "Create a new Pool"
+ When I fill in "pool_name" with "mockpool"
+ And I press "Save"
+ Then I should be on the show pool page
+ And I should see "Pool added"
+ And I should see "mockpool"
+ And I should have a pool named "mockpool"
+
+ Scenario: View Pool's Hardware Profiles
+ Given I own a pool named "mockpool"
+ And the Pool has the following Hardware Profiles:
+ | name | memory | storage | architecture |
+ | m1-small | 1.7 | 160.0 | i386 |
+ | m1-large | 7.5 | 850.0 | x86_64 |
+ | m1-xlarge | 15.0 | 1690.0 | x86_64 |
+ And I am on the homepage
+ When I follow "mockpool"
+ Then I should be on the show pool page
+ When I follow "Hardware Profiles"
+ Then I should see the following:
+ | m1-small | 1.7 | 160.0 | i386 |
+ | m1-large | 7.5 | 850.0 | x86_64 |
+ | m1-xlarge | 15.0 | 1690.0 | x86_64 |
+
+ Scenario: View Pool's Realms
+ Given I own a pool named "mockpool"
+ And the Pool has the following Realms named "Europe, United States"
+ And I am on the homepage
+ When I follow "mockpool"
+ Then I should be on the show pool page
+ When I follow "Realms"
+ Then I should see "Europe"
+ And I should see "United States"
+
+ Scenario: View Pool's Images
+ Given I own a pool named "mockpool"
+ And the Pool has the following Images:
+ | name | architecture |
+ | Fedora 10 | x86_64 |
+ | Fedora 10 | i386 |
+ | JBoss | i386 |
+ And I am on the homepage
+ When I follow "mockpool"
+ Then I should be on the show pool page
+ When I follow "View Images"
+ Then I should see the following:
+ | Fedora 10 | x86_64 |
+ | Fedora 10 | i386 |
+ | JBoss | i386 |
diff --git a/src/features/step_definitions/pool_steps.rb
b/src/features/step_definitions/pool_steps.rb
new file mode 100644
index 0000000..4012a42
--- /dev/null
+++ b/src/features/step_definitions/pool_steps.rb
@@ -0,0 +1,50 @@
+Given /^I am an authorised user$/ do
+ @admin_permission = Factory :admin_permission
+ @user = @admin_permission.user
+end
+
+Given /^I own a pool named "([^\"]*)"$/ do |name|
+ @pool = Factory(:pool, :name => name)
+ @user.owned_pools << @pool
+end
+
+Given /^the Pool has the following Hardware Profiles:$/ do |table|
+ table.hashes.each do |hash|
+ @pool.hardware_profiles << Factory(:hardware_profile_auto, hash)
+ end
+end
+
+Given /^the Pool has the following Realms named "([^\"]*)"$/ do |names|
+ @cloud_account = Factory :cloud_account
+ @provider = @cloud_account.provider
+
+ names.split(", ").each do |name|
+ @pool.realms << Factory(:realm, :name => name, :provider => @provider)
+ end
+ @pool.cloud_accounts << @cloud_account
+
+end
+
+Given /^the Pool has the following Images:$/ do |table|
+ table.hashes.each do |hash|
+ hash["pool"] = @pool
+ @pool.images << Factory(:image, hash)
+ end
+end
+
+Given /^there is not a pool named "([^\"]*)"$/ do |name|
+ Pool.find_by_name(name).should be_nil
+end
+
+Then /^I should have a pool named "([^\"]*)"$/ do |name|
+ Pool.find_by_name(name).should_not be_nil
+ Pool.find_by_name(name).permissions.size.should == 1
+end
+
+Then /^I should see the following:$/ do |table|
+ table.raw.each do |array|
+ array.each do |text|
+ Then 'I should see "' + text + '"'
+ end
+ end
+end
\ No newline at end of file
diff --git a/src/features/support/env.rb b/src/features/support/env.rb
index 341854f..2d6e9a1 100644
--- a/src/features/support/env.rb
+++ b/src/features/support/env.rb
@@ -21,6 +21,14 @@ Webrat.configure do |config|
config.open_error_files = false # Set to true if you want error pages to pop
up in the browser
end
+Provider.class_eval do
+ alias_method :original_validate, :validate
+ def validate
+ if !nil_or_empty(url)
+ # errors.add("url", "must be a valid provider url") unless
valid_framework?
+ end
+ end
+end
# If you set this to false, any error raised from within your app will bubble
# up to your step definition and out to cucumber unless you catch it somewhere
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index 7c16ade..685669c 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -29,6 +29,17 @@ module NavigationHelpers
when /the new provider page/
new_provider_path
+ when /the new pool page/
+ new_pool_path
+
+ when /the show pool page/
+ pool_path
+
+ when /the pool realms page/
+ pool_realms_path
+
+ when /the pool hardware profiles page/
+ hardware_profiles_pool_path
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
diff --git a/src/spec/factories/cloud_account.rb
b/src/spec/factories/cloud_account.rb
new file mode 100644
index 0000000..b1e4cc4
--- /dev/null
+++ b/src/spec/factories/cloud_account.rb
@@ -0,0 +1,5 @@
+Factory.define :cloud_account do |f|
+ f.sequence(:username) { |n| "testUser#(n)" }
+ f.password "testPassword"
+ f.association :provider
+end
\ No newline at end of file
diff --git a/src/spec/factories/hardware_profile.rb
b/src/spec/factories/hardware_profile.rb
index 752adac..43f63f3 100644
--- a/src/spec/factories/hardware_profile.rb
+++ b/src/spec/factories/hardware_profile.rb
@@ -22,3 +22,10 @@ Factory.define :pool_hwp1, :parent => :hardware_profile do
|p|
p.external_key 'pool_hwp1_key'
p.architecture 'x86_64'
end
+
+Factory.define :hardware_profile_auto, :parent => :hardware_profile do |p|
+ p.external_key { |hp| hp.name + "_key" }
+ p.storage 160
+ p.memory 1024
+ p.architecture "i386"
+end
\ No newline at end of file
diff --git a/src/spec/factories/image.rb b/src/spec/factories/image.rb
new file mode 100644
index 0000000..1221c05
--- /dev/null
+++ b/src/spec/factories/image.rb
@@ -0,0 +1,6 @@
+Factory.define :image do |i|
+ i.sequence(:name) { |n| "mock_image#{n}" }
+ i.sequence(:external_key) { |n| "mock_external_key#{n}" }
+ i.architecture "i386"
+ i.association(:pool)
+end
\ No newline at end of file
diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb
index 90976ff..1d3e3b7 100644
--- a/src/spec/factories/provider.rb
+++ b/src/spec/factories/provider.rb
@@ -1,5 +1,7 @@
Factory.define :provider do |p|
p.sequence(:name) { |n| "provider#{n}" }
+ p.cloud_type 'mock'
+ p.url { |p| "http://www." + p.name + ".com/api" }
end
Factory.define :mock_provider, :parent => :provider do |p|
@@ -14,4 +16,4 @@ Factory.define :mock_provider2, :parent => :provider do |p|
p.cloud_type 'mock'
p.url 'http://localhost:3001/api'
p.after_create { |p| p.realms << Factory(:realm3, :provider => p) }
-end
+end
\ No newline at end of file
diff --git a/src/spec/factories/realm.rb b/src/spec/factories/realm.rb
index 93a6516..f4df03b 100644
--- a/src/spec/factories/realm.rb
+++ b/src/spec/factories/realm.rb
@@ -1,6 +1,7 @@
Factory.define :realm do |r|
r.sequence(:name) { |n| "realm#{n}" }
r.sequence(:external_key) { |n| "key#{n}" }
+ r.association(:provider)
end
Factory.define :realm1, :parent => :realm do |r|
--
1.6.6.1
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel