Sha256: addb3fd84d609c6ed651149cbcab26348145cf9b98381cac5e63cc896e62a3d2

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

require 'tests/common'

module DeltacloudUnitTest
  class RealmsTest < Test::Unit::TestCase
    include Rack::Test::Methods

    def app
      Sinatra::Application
    end

    def test_it_not_require_authentication
      require_authentication?('/api/realms').should_not == true
    end

    def test_it_returns_instance_states
      do_xml_request '/api/instance_states', {}, true
      (last_xml_response/'states/state').map.size.should > 0
    end

    def test_each_state_has_transition
      do_xml_request '/api/instance_states', {}, true
      (last_xml_response/'states/state').each do |state|
        next if state['name'].eql?('finish') # Finnish state doesn't have transitions
        (state/'transition').map.size.should > 0
        (state/'transition').each do |transition|
          transition['to'].should_not == nil
        end
      end
    end

    def test_it_responses_to_json
      do_request '/api/instance_states', {}, false, { :format => :json }
      JSON::parse(last_response.body).class.should == Array
      JSON::parse(last_response.body).first['transitions'].class.should == Array
      JSON::parse(last_response.body).first['name'].should == 'start'
    end

    def test_it_responses_to_html
      do_request '/api/instance_states', {}, false, { :format => :html }
      last_response.status.should == 200
      Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
    end

    def test_it_responses_to_png
      do_request '/api/instance_states', { :format => 'png' }, false
      last_response.status.should == 200
      last_response.headers['Content-Type'].should == 'image/png'
    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
steamcannon-deltacloud-core-0.0.7.2 tests/instance_states_test.rb
steamcannon-deltacloud-core-0.0.7.2-java tests/instance_states_test.rb
steamcannon-deltacloud-core-0.0.7.1 tests/instance_states_test.rb
steamcannon-deltacloud-core-0.0.7.1-java tests/instance_states_test.rb
deltacloud-core-0.0.7 tests/instance_states_test.rb