Parent

Included Modules

Class/Module Index [+]

Quicksearch

DeltacloudUnitTest::HardwareProfilesTest

Public Instance Methods

app() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 24
def app
  Sinatra::Application
end
test_hardware_profiles_have_name() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 40
def test_hardware_profiles_have_name
  get_auth_url '/api/hardware_profiles'
  (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
    (profile/'name').text.should_not == nil
  end
end
test_hardware_profiles_have_unique_id() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 56
def test_hardware_profiles_have_unique_id
  get_auth_url '/api/hardware_profiles'
  ids = []
  (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
    ids << profile['id']
  end
  ids.should == ids.uniq
end
test_hardware_profiles_have_unique_name() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 47
def test_hardware_profiles_have_unique_name
  get_auth_url '/api/hardware_profiles'
  names = []
  (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
    names << (profile/'name').text
  end
  names.should == names.uniq
end
test_img1_has_correct_attributes() click to toggle source
# File tests/drivers/mock/images_test.rb, line 44
def test_img1_has_correct_attributes
  get_auth_url '/api/images', {}
  image = (last_xml_response/'images/image[@id="img1"]')
  test_image_attributes(image)
end
test_it_can_filter_using_architecture() click to toggle source
# File tests/drivers/mock/images_test.rb, line 86
def test_it_can_filter_using_architecture
  get_auth_url '/api/images', { :architecture => 'x86_64' }
  (last_xml_response/'images/image').length.should == 1
  (last_xml_response/'images/image/architecture').first.text.should == 'x86_64'
end
test_it_can_filter_using_owner_id() click to toggle source
# File tests/drivers/mock/images_test.rb, line 75
def test_it_can_filter_using_owner_id
  get_auth_url '/api/images', { :owner_id => 'mockuser' }
  (last_xml_response/'images/image').length.should == 1
  (last_xml_response/'images/image/owner_id').first.text.should == 'mockuser'
end
test_it_can_filter_using_unknown_architecture() click to toggle source
# File tests/drivers/mock/images_test.rb, line 92
def test_it_can_filter_using_unknown_architecture
  get_auth_url '/api/images', { :architecture => 'unknown_arch' }
  (last_xml_response/'images/image').length.should == 0
end
test_it_can_filter_using_unknown_owner_id() click to toggle source
# File tests/drivers/mock/images_test.rb, line 81
def test_it_can_filter_using_unknown_owner_id
  get_auth_url '/api/images', { :architecture => 'unknown_user' }
  (last_xml_response/'images/image').length.should == 0
end
test_it_creates_and_destroys_image_from_instance() click to toggle source
# File tests/drivers/mock/images_test.rb, line 116
def test_it_creates_and_destroys_image_from_instance
  post_url "/api/images", { :name => "img4", :description => "Test::Unit image", :instance_id => "inst1"}
  last_response.status.should == 201
  last_response.headers['Location'].should_not == nil
  get_auth_url last_response.headers['Location'], {}
  (last_xml_response/'instance/name').should_not == nil
  delete_url "/api/images/img4", {}
  last_response.status.should == 204
  get_auth_url "/api/images/img4", {}
  last_response.status.should == 404
end
test_it_has_correct_attributes_set() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 33
def test_it_has_correct_attributes_set
  get_auth_url '/api/hardware_profiles'
  (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
    profile.attributes.keys.sort.should == [ 'href', 'id' ]
  end
end
test_it_has_unique_ids() click to toggle source
# File tests/drivers/mock/images_test.rb, line 56
def test_it_has_unique_ids
  get_auth_url '/api/images', {}
  ids = []
  (last_xml_response/'images/image').each do |image|
    ids << image['id'].to_s
  end
  ids.sort.should == ids.sort.uniq
end
test_it_has_valid_urls() click to toggle source
# File tests/drivers/mock/images_test.rb, line 65
def test_it_has_valid_urls
  get_auth_url '/api/images', {}
  ids = []
  images = (last_xml_response/'images/image')
  images.each do |image|
    get_auth_url image['href'].to_s, {}
    (last_xml_response/'image').first['href'].should == image['href'].to_s
  end
end
test_it_require_authentication() click to toggle source
# File tests/drivers/mock/images_test.rb, line 28
def test_it_require_authentication
  require_authentication?('/api/images').should == true
end
test_it_responses_to_html() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 87
def test_it_responses_to_html
  get_url '/api/hardware_profiles', {}, { :format => :html }
  last_response.status.should == 200
  Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
  get_url '/api/hardware_profiles/m1-xlarge', {}, { :format => :html }
  last_response.status.should == 200
  Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
end
test_it_responses_to_json() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 77
def test_it_responses_to_json
  get_url '/api/hardware_profiles', {}, { :format => :json }
  JSON::parse(last_response.body).class.should == Hash
  JSON::parse(last_response.body)['hardware_profiles'].class.should == Array
  get_url '/api/hardware_profiles/m1-xlarge', {}, { :format => :json }
  last_response.status.should == 200
  JSON::parse(last_response.body).class.should == Hash
  JSON::parse(last_response.body)['hardware_profile'].class.should == Hash
end
test_it_returns_error_on_wrong_name() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 96
def test_it_returns_error_on_wrong_name
  get_url '/api/hardware_profiles/m1-unknown-wrongname', {}, { :format => :html }
  last_response.status.should == 404
  get_auth_url '/api/hardware_profiles/m1-unknown-wrongname'
  last_response.status.should == 404
  get_url '/api/hardware_profiles/m1-unknown-wrongname', {}, { :format => :json }
  last_response.status.should == 404
end
test_it_returns_hardware_profiles() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 28
def test_it_returns_hardware_profiles
  get_url '/api/hardware_profiles'
  (last_xml_response/'hardware_profiles/hardware_profile').length.should > 0
end
test_it_returns_images() click to toggle source
# File tests/drivers/mock/images_test.rb, line 32
def test_it_returns_images
  get_auth_url '/api/images', {}
  (last_xml_response/'images/image').length.should > 0
end
test_it_returns_valid_hardware_profile() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 71
def test_it_returns_valid_hardware_profile
  get_auth_url '/api/hardware_profiles/m1-xlarge'
  profile = (last_xml_response/'hardware_profile')
  test_profile_properties(profile)
end
test_it_returns_valid_image() click to toggle source
# File tests/drivers/mock/images_test.rb, line 50
def test_it_returns_valid_image
  get_auth_url '/api/images/img1', {}
  image = (last_xml_response/'image')
  test_image_attributes(image)
end
test_m1_xlarge_profile_has_correct_attributes() click to toggle source
# File tests/drivers/mock/hardware_profiles_test.rb, line 65
def test_m1_xlarge_profile_has_correct_attributes
  get_auth_url '/api/hardware_profiles'
  profile = (last_xml_response/'hardware_profiles/hardware_profile[@id="m1-xlarge"]')
  test_profile_properties(profile)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.