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
# 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
# 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
# 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
# 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
# File tests/deltacloud/collections/instance_states_collection_test.rb, line 9 def app; Deltacloud::API; end
# File tests/drivers/google/buckets_test.rb, line 26 def blob_name_google "testblobk1ds91kVdelmegoogel" end
# File tests/drivers/google/buckets_test.rb, line 22 def bucket_name_google "testbucki2rpux3wdelmegoogel" end
# 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
# 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
# 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
# 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
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
# File tests/drivers/google/common.rb, line 12 def created_blob_local_file File.join(File.dirname(__FILE__),"data","deltacloud_blob_test.png") end
# File tests/drivers/ec2/common.rb, line 9 def credentials Deltacloud::Test::config.credentials('ec2') end
# 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
# 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
# File tests/test_helper.rb, line 40 def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
# File tests/test_helper.rb, line 36 def headers; last_response.headers; end
# File tests/test_helper.rb, line 39 def json; JSON::parse(response_body); end
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
# File tests/drivers/openstack/common.rb, line 12 def openstack_image_id 'bf7ce59a-d9f9-45d4-9313-f45b16436602' end
# 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
# 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
# File tests/test_helper.rb, line 37 def response_body; last_response.body; end
# File tests/test_helper.rb, line 41 def root_url(url=''); Deltacloud.default_frontend.root_url + url; end
# 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
# File tests/test_helper.rb, line 35 def status; last_response.status; end
# File tests/test_helper.rb, line 38 def xml; Nokogiri::XML(response_body); end