Sha256: 46222358a6cba325b86d0bd5366cb504a7c7322536cae13531f70a2a26b9ab59

Contents?: true

Size: 1.69 KB

Versions: 10

Compression:

Stored size: 1.69 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', {}, false, { :format => :png }
      last_response.status.should == 200
      last_response.headers['Content-Type'].should == 'image/png'
      #last_response.headers['Content-Length'].should == '4371'
    end

  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
bbrowning-deltacloud-core-0.0.6.1-java tests/instance_states_test.rb
bbrowning-deltacloud-core-0.0.6-java tests/instance_states_test.rb
bbrowning-deltacloud-core-0.0.6 tests/instance_states_test.rb
deltacloud-core-0.0.6 tests/instance_states_test.rb
bbrowning-deltacloud-core-0.0.4 tests/instance_states_test.rb
bbrowning-deltacloud-core-0.0.4-java tests/instance_states_test.rb
deltacloud-core-0.0.5 tests/instance_states_test.rb
deltacloud-core-0.0.4 tests/instance_states_test.rb
bbrowning-deltacloud-core-0.0.3.1 tests/instance_states_test.rb
deltacloud-core-0.0.3 tests/instance_states_test.rb