class Object

Constants

CMWG_NAMESPACE
CURL_LOADED
DATA_DIR
DEFAULT_CONFIG
INSTANCE_ID
MULTIPART_LOADED
REXML_FORMATTERS

Public Class Methods

__name__() click to toggle source

Destroy test instance when all test are done

# File tests/drivers/gogrid/instances_test.rb, line 29
def self.__name__
  # record_retries below calls this
  "instances_test_class"
end
create_test_instance() click to toggle source
# File tests/drivers/gogrid/instances_test.rb, line 19
def self.create_test_instance
  driver = Deltacloud::new(:gogrid, credentials)
  VCR.use_cassette "instances_create_test_instance" do
    @@instance = driver.instance(:id => INSTANCE_ID)
    @@instance ||= driver.create_instance(fixed_image_id,
                                          :name=> INSTANCE_ID)
  end
end
destroy_test_instance() click to toggle source
# File tests/drivers/gogrid/instances_test.rb, line 34
def self.destroy_test_instance
  driver = Deltacloud::new(:gogrid, credentials)

  # Go fast when running off a recording
  opts = record_retries('', :time_between_retry => 60)
  @@instance.wait_for!(driver, opts) do |i|
    i.actions.include?(:destroy)
  end

  VCR.use_cassette "instances_destroy_test_instance" do
    driver.destroy_instance(@@instance.id)
    @@instance = nil
  end
end
standard_index_operation(opts={}) click to toggle source
# File lib/deltacloud/helpers/rabbit_helper.rb, line 19
def self.standard_index_operation(opts={})
  collection_name = @collection_name
  operation :index, :with_capability => opts[:capability] || collection_name do
    control { filter_all collection_name }
  end
end
standard_show_operation(opts={}) click to toggle source
# File lib/deltacloud/helpers/rabbit_helper.rb, line 26
def self.standard_show_operation(opts={})
  collection_name = @collection_name
  operation :show, :with_capability => opts[:capability] || collection_name do
    control { show collection_name.to_s.singularize.intern }
  end
end

Public Instance Methods

app() click to toggle source
# File tests/ec2/server_test.rb, line 9
def app; Deltacloud::EC2::API; end
blob_name_google() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 26
def blob_name_google
  "testblobk1ds91kVdelmegoogel"
end
bucket_name_google() click to toggle source
# File tests/drivers/google/buckets_test.rb, line 22
def bucket_name_google
  "testbucki2rpux3wdelmegoogel"
end
check(obj) click to toggle source
# File tests/cimi/spec/cimi/model/schema_spec.rb, line 95
def check(obj)
  obj.wont_be_nil
  obj[:meter].href.must_equal 'http://example.org/'
end
check_empty_struct(obj) click to toggle source
# File tests/cimi/spec/cimi/model/schema_spec.rb, line 178
def check_empty_struct(obj)
  obj.wont_be_nil
  obj[:struct].wont_be_nil
  obj[:struct].scalar.must_be_nil
  obj[:struct].href.must_be_nil
end
check_struct(obj, opts = {}) click to toggle source
# File tests/cimi/spec/cimi/model/schema_spec.rb, line 167
def check_struct(obj, opts = {})
  obj.wont_be_nil
  obj[:struct].wont_be_nil
  obj[:struct].scalar.must_equal "v1"
  if opts[:nil_href]
    obj[:struct].href.must_be_nil
  else
    obj[:struct].href.must_equal "http://example.org/"
  end
end
check_structs(obj) click to toggle source
# File tests/cimi/spec/cimi/model/schema_spec.rb, line 235
def check_structs(obj)
  obj.wont_be_nil
  obj[:structs].size.must_equal 2
  obj[:structs][0].scalar.must_equal "v1"
  obj[:structs][0].href.must_equal "http://example.org/1"
  obj[:structs][1].scalar.must_equal "v2"
  obj[:structs][1].href.must_equal "http://example.org/2"
end
create_resources() click to toggle source

Setup resources we need for the tests

# File tests/drivers/ec2/common.rb, line 32
def create_resources
  VCR.use_cassette "create_resources" do
    driver = Deltacloud::new(:ec2, credentials)
    @@ec2 = driver.client
    @@vpc = @@ec2.create_vpc("172.16.0.0/16").first
    @@subnet = @@ec2.create_subnet(@@vpc[:vpc_id], "172.16.3.0/24", "us-east-1b").first
  end
end
created_blob_local_file() click to toggle source
# File tests/drivers/google/common.rb, line 12
def created_blob_local_file
  File.join(File.dirname(__FILE__),"data","deltacloud_blob_test.png")
end
credentials() click to toggle source

Credentials used to access RHEV-M server

NOTE: If these are changed, the VCR fixtures need to be re-recorded

# File tests/drivers/rhevm/common.rb, line 9
def credentials
  {
    :user => 'vdcadmin@rhev.lab.eng.brq.redhat.com',
    :password => '123456',
    :provider => 'https://rhev30-dc.lab.eng.brq.redhat.com:8443/api;645e425e-66fe-4ac9-8874-537bd10ef08d'
  }
end
destroy_resources() click to toggle source
# File tests/drivers/ec2/common.rb, line 41
def destroy_resources
  VCR.use_cassette "destroy_resources" do
    @@ec2.delete_subnet(@@subnet[:subnet_id]) if @@subnet
    @@ec2.delete_vpc(@@vpc[:vpc_id]) if @@vpc
  end
end
fixed_image_id() click to toggle source
# File tests/drivers/gogrid/common.rb, line 9
def fixed_image_id
  # A fixed image we use throughout the tests; if GoGrid ever removes it
  # we need to change it here
  "9928"
end
formats() click to toggle source
# File tests/test_helper.rb, line 40
def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
headers() click to toggle source
# File tests/test_helper.rb, line 36
def headers; last_response.headers; end
json() click to toggle source
# File tests/test_helper.rb, line 39
def json; JSON::parse(response_body); end
library_present?(name) click to toggle source

See if we can require name and return true if the library is there, false otherwise. Note that, as a side effect, the library will be loaded

# File bin/deltacloudd, line 28
def library_present?(name)
  begin
    require name
    true
  rescue LoadError
    false
  end
end
openstack_image_id() click to toggle source
# File tests/drivers/openstack/common.rb, line 12
def openstack_image_id
  'bf7ce59a-d9f9-45d4-9313-f45b16436602'
end
parse_xml(xml, opts = {}) click to toggle source
# File tests/cimi/spec/spec_helper.rb, line 28
def parse_xml(xml, opts = {})
  opts[:force_content] = true
  opts[:keep_root] = true unless opts.has_key?(:keep_root)
  XmlSimple.xml_in(xml, opts)
end
record_retries(name='', opts = {}) click to toggle source
# File tests/test_helper.rb, line 23
def record_retries(name='', opts = {})
  opts[:before] = Proc.new { |r, &block|
    VCR.use_cassette("#{__name__}-#{name.empty? ? '' : "#{name}-"}#{r}", &block)
  }
  if VCR.configuration.default_cassette_options[:record] == :none
    opts[:time_between_retry] = 0
  end
  opts
end
response_body() click to toggle source
# File tests/test_helper.rb, line 37
def response_body; last_response.body; end
root_url() click to toggle source

The #root_url here is '/' because the application is not mounted and so by default Sinatra mounts it on '/'

# File tests/ec2/common.rb, line 25
def root_url; '/'; end
should_properly_serialize_model(model_class, xml, json) click to toggle source
# File tests/cimi/spec/spec_helper.rb, line 103
def should_properly_serialize_model(model_class, xml, json)
  # Roundtrip in same format
  model_class.from_xml(xml).must_serialize_to xml, :fmt => :xml
  model_class.from_json(json).must_serialize_to json, :fmt => :json
  # Roundtrip crossing format
  model_class.from_xml(xml).must_serialize_to json, :fmt => :json
  model_class.from_json(json).must_serialize_to xml, :fmt => :xml
end
status() click to toggle source
# File tests/test_helper.rb, line 35
def status; last_response.status; end
xml() click to toggle source
# File tests/test_helper.rb, line 38
def xml; Nokogiri::XML(response_body); end