deltacloud-core 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -9
- data/config.ru +2 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +0 -1
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml +5 -0
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml +5 -0
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml +5 -0
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml +5 -0
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml +5 -0
- data/lib/deltacloud/drivers/mock/data/buckets/bucket1.yml +2 -0
- data/lib/deltacloud/drivers/mock/data/buckets/bucket2.yml +2 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +77 -1
- data/lib/deltacloud/helpers/application_helper.rb +5 -2
- data/lib/deltacloud/models/tag.rb +43 -0
- data/server.rb +3 -1
- data/views/images/show.html.haml +1 -1
- data/views/keys/show.xml.haml +2 -3
- data/views/tags/index.html.haml +1 -0
- metadata +17 -23
- data/lib/sinatra/respond_to_old.rb +0 -253
- data/test.rb +0 -8
- data/tests/api_test.rb +0 -37
- data/tests/hardware_profiles_test.rb +0 -120
- data/tests/images_test.rb +0 -111
- data/tests/instance_states_test.rb +0 -51
- data/tests/instances_test.rb +0 -222
- data/tests/realms_test.rb +0 -78
- data/tests/url_for_test.rb +0 -50
data/tests/realms_test.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'tests/common'
|
2
|
-
|
3
|
-
module DeltacloudUnitTest
|
4
|
-
class RealmsTest < Test::Unit::TestCase
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def app
|
8
|
-
Sinatra::Application
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_it_not_require_authentication
|
12
|
-
require_authentication?('/api/realms').should_not == true
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_it_returns_realms
|
16
|
-
do_xml_request '/api/realms', {}, true
|
17
|
-
(last_xml_response/'realms/realm').map.size.should > 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_it_has_correct_attributes_set
|
21
|
-
do_xml_request '/api/realms', {}, true
|
22
|
-
(last_xml_response/'realms/realm').each do |realm|
|
23
|
-
realm.attributes.keys.sort.should == [ 'href', 'id' ]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_us_has_correct_attributes
|
28
|
-
do_xml_request '/api/realms', {}, true
|
29
|
-
realm = (last_xml_response/'realms/realm[@id="us"]')
|
30
|
-
test_realm_attributes(realm)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_it_returns_valid_realm
|
34
|
-
do_xml_request '/api/realms/us', {}, true
|
35
|
-
realm = (last_xml_response/'realm')
|
36
|
-
test_realm_attributes(realm)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_it_has_unique_ids
|
40
|
-
do_xml_request '/api/realms', {}, true
|
41
|
-
ids = []
|
42
|
-
(last_xml_response/'realms/realm').each do |realm|
|
43
|
-
ids << realm['id'].to_s
|
44
|
-
end
|
45
|
-
ids.sort.should == ids.sort.uniq
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_it_responses_to_json
|
49
|
-
do_request '/api/realms', {}, false, { :format => :json }
|
50
|
-
JSON::parse(last_response.body).class.should == Hash
|
51
|
-
JSON::parse(last_response.body)['realms'].class.should == Array
|
52
|
-
|
53
|
-
do_request '/api/realms/us', {}, false, { :format => :json }
|
54
|
-
last_response.status.should == 200
|
55
|
-
JSON::parse(last_response.body).class.should == Hash
|
56
|
-
JSON::parse(last_response.body)['realm'].class.should == Hash
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_it_responses_to_html
|
60
|
-
do_request '/api/realms', {}, false, { :format => :html }
|
61
|
-
last_response.status.should == 200
|
62
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
63
|
-
|
64
|
-
do_request '/api/realms/us', {}, false, { :format => :html }
|
65
|
-
last_response.status.should == 200
|
66
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def test_realm_attributes(realm)
|
72
|
-
(realm/'name').should_not == nil
|
73
|
-
(realm/'limit').should_not == nil
|
74
|
-
['AVAILABLE'].include?((realm/'state').text).should == true
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
data/tests/url_for_test.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'tests/common'
|
2
|
-
|
3
|
-
module DeltacloudUnitTest
|
4
|
-
class UrlForTest < Test::Unit::TestCase
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def app
|
8
|
-
Sinatra::Application
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_it_works_for_root
|
12
|
-
verify_url_for("/", "/")
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_it_works_for_root_absolute
|
16
|
-
verify_url_for("/", "http://localhost/", :full)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_it_works_with_spaces
|
20
|
-
verify_url_for("/url with spaces", "/url%20with%20spaces")
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_it_works_when_given_absolute
|
24
|
-
verify_url_for("http://test.com", "http://test.com")
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_it_works_when_not_at_root_context
|
28
|
-
verify_url_for("/", "context/", :path_only, {}, {"SCRIPT_NAME" => "context"})
|
29
|
-
end
|
30
|
-
|
31
|
-
def verify_url_for(url, expected_url, mode=:path_only, params={}, rack_env={})
|
32
|
-
# generate a unique url for each test
|
33
|
-
test_url = "/url_for_test/#{expected_url.hash}/#{Time.now.to_i}"
|
34
|
-
# Create our sinatra test endpoint
|
35
|
-
self.class.create_test_url_content(test_url, url, mode)
|
36
|
-
|
37
|
-
# verify the generated url matches what we expect
|
38
|
-
get test_url, params, rack_env
|
39
|
-
last_response.body.should == expected_url
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.create_test_url_content(test_url, url_content, mode)
|
43
|
-
get test_url do
|
44
|
-
content_type "text/plain"
|
45
|
-
url_for(url_content, mode)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|