From 36d4dcbefe6487058c5fbcbb6d8bf1ba3cfb7158 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Tue, 10 Apr 2012 10:41:18 -0400 Subject: [PATCH] Update tests and mocks based on real pro data. --- lib/fog/hp/requests/compute/create_server.rb | 20 +++++++++++++++----- tests/hp/requests/compute/server_tests.rb | 17 +++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/fog/hp/requests/compute/create_server.rb b/lib/fog/hp/requests/compute/create_server.rb index 2714f070d..0eaf96015 100644 --- a/lib/fog/hp/requests/compute/create_server.rb +++ b/lib/fog/hp/requests/compute/create_server.rb @@ -101,11 +101,16 @@ module Fog response = Excon::Response.new response.status = 202 + if options['security_groups'] + sec_group_name = options['security_groups'][0] + else + sec_group_name = "default" + end data = { - 'addresses' => { "private"=>[{"version"=>4, "addr"=>Fog::HP::Mock.ip_address}] }, - 'flavor' => {"id"=>"1", "links"=>[{"href"=>"http://nova1:8774/admin/flavors/1", "rel"=>"bookmark"}]}, - 'id' => Fog::Mock.random_numbers(6).to_s, - 'image' => {"id"=>"3", "links"=>[{"href"=>"http://nova1:8774/admin/images/3", "rel"=>"bookmark"}]}, + 'addresses' => {}, + 'flavor' => {"id"=>"#{flavor_id}", "links"=>[{"href"=>"http://nova1:8774/admin/flavors/#{flavor_id}", "rel"=>"bookmark"}]}, + 'id' => Fog::Mock.random_numbers(6).to_i, + 'image' => {"id"=>"#{image_id}", "links"=>[{"href"=>"http://nova1:8774/admin/images/#{image_id}", "rel"=>"bookmark"}]}, 'links' => [{"href"=>"http://nova1:8774/v1.1/admin/servers/5", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/servers/5", "rel"=>"bookmark"}], 'hostId' => "123456789ABCDEF01234567890ABCDEF", 'metadata' => options['metadata'] || {}, @@ -114,9 +119,14 @@ module Fog 'accessIPv6' => options['accessIPv6'] || "", 'progress' => 0, 'status' => 'BUILD', + 'created' => "2012-01-01T13:32:20Z", + 'updated' => "2012-01-01T13:32:20Z", 'user_id' => Fog::HP::Mock.user_id.to_s, 'tenant_id' => Fog::HP::Mock.user_id.to_s, - 'key_name' => options['key_name'] || "", + 'uuid' => "95253a45-9ead-43c6-90b3-65da2ef048b3", + 'config_drive' => "", + #'security_groups' => [{"name"=>"#{sec_group_name}", "links"=>[{"href"=>"http://nova1:8774/v1.1/admin//os-security-groups/111", "rel"=>"bookmark"}], "id"=>111}], + 'key_name' => options['key_name'] || "" } self.data[:last_modified][:servers][data['id']] = Time.now self.data[:servers][data['id']] = data diff --git a/tests/hp/requests/compute/server_tests.rb b/tests/hp/requests/compute/server_tests.rb index fd073a570..36cb52755 100644 --- a/tests/hp/requests/compute/server_tests.rb +++ b/tests/hp/requests/compute/server_tests.rb @@ -1,11 +1,9 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do @server_format = { - 'addresses' => { - 'private' => [Hash] - }, + 'addresses' => Fog::Nullable::Hash, 'flavor' => Hash, - 'id' => String, + 'id' => Integer, 'image' => Hash, 'links' => [Hash], 'hostId' => String, @@ -15,14 +13,21 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do 'accessIPv6' => Fog::Nullable::String, 'progress' => Fog::Nullable::Integer, 'status' => String, + 'created' => String, + 'updated' => String, 'user_id' => String, 'tenant_id' => String, + 'uuid' => String, + 'config_drive' => Fog::Nullable::String, + #'security_groups' => [Hash], 'key_name' => Fog::Nullable::String } @list_servers_format = { + 'uuid' => Fog::Nullable::String, + 'links' => [Hash], 'name' => String, - 'id' => String + 'id' => Integer } @get_console_output_format = { @@ -111,7 +116,7 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do Fog::Compute[:hp].reboot_server(0) end - tests("#change_password_server(0}, 'new_password')").raises(Fog::Compute::HP::NotFound) do + tests("#change_password_server(0}, 'new_password')").raises(Excon::Errors::InternalServerError) do Fog::Compute[:hp].change_password_server(0, 'new_password') end