Sha256: 90baf1a5e8acc68e1102f1eea43e7be1f11ab403736e59abfac399172de4bc40

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require 'rubygems'
require 'require_relative' if RUBY_VERSION < '1.9'
require 'minitest/autorun'
require_relative './common.rb'

describe CIMI::Collections::MachineImages do

  before do
    def app; run_frontend(:cimi) end
    authorize 'mockuser', 'mockpassword'
    @collection = CIMI::Collections.collection(:machine_images)
  end

  it 'has index operation' do
    @collection.operation(:index).must_equal CIMI::Rabbit::MachineImagesCollection::IndexOperation
  end

  it 'has show operation' do
    @collection.operation(:show).must_equal CIMI::Rabbit::MachineImagesCollection::ShowOperation
  end

  it 'returns list of images in various formats with index operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/machine_images'
      status.must_equal 200
    end
  end

  it 'should allow to retrieve the single image' do
    get root_url '/machine_images/img1'
    status.must_equal 200
    xml.root.name.must_equal 'MachineImage'
  end

  describe "filtering with $select" do
    def machines(*select)
      url = "/machine_images"
      url += "?$select=#{select.join(",")}" unless select.empty?
      get root_url url
      status.must_equal 200
    end

    it 'should filter collection members' do
      machines :description
      (xml/'id').wont_be_empty
      nimages = (xml/'MachineImage').size
      (xml/'MachineImage/description').size.must_equal nimages
      (xml/'MachineImage/id').must_be_empty
    end

    it 'should filter by multiple attributes' do
      machines :description, :id
      (xml/'id').wont_be_empty
      nimages = (xml/'MachineImage').size
      (xml/'MachineImage/description').size.must_equal nimages
      (xml/'MachineImage/id').size.must_equal nimages
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.1.3 tests/cimi/collections/machine_images_test.rb
deltacloud-core-1.1.2 tests/cimi/collections/machine_images_test.rb