diff --git a/devops-client/lib/devops-client/i18n.rb b/devops-client/lib/devops-client/i18n.rb index 7efcf67..2a3bb51 100644 --- a/devops-client/lib/devops-client/i18n.rb +++ b/devops-client/lib/devops-client/i18n.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 module I18n @@lang = {} diff --git a/devops-client/locales/ru.yml b/devops-client/locales/ru.yml index 15be27b..b45e3df 100644 --- a/devops-client/locales/ru.yml +++ b/devops-client/locales/ru.yml @@ -1,3 +1,4 @@ +# encoding: UTF-8 ru: config: invalid: diff --git a/devops-service/features/flavor.feature b/devops-service/features/flavor.feature new file mode 100644 index 0000000..273f670 --- /dev/null +++ b/devops-service/features/flavor.feature @@ -0,0 +1,47 @@ +Feature: flavors + + @flavor + Scenario: Get list of openstack flavors + When I send GET '/v2.0/flavors/openstack' query + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an array + And response array should contains elements like: + """ + [ + { + "id" => "flavor_id", + "v_cpus" => "v_cpus", + "ram" => "ram", + "disk" => "disk" + } + ] + """ + + @flavor + Scenario: Get list of ec2 flavors + When I send GET '/v2.0/flavors/ec2' query + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an array + And response array should contains elements like: + """ + [ + { + "id": "t1.micro", + "cores": 2, + "disk": 0, + "name": "Micro Instance", + "ram": 613 + } + ] + """ + + @flavor + Scenario: Get list of static flavors + When I send GET '/v2.0/flavors/static' query + Then response should be '200' + And the Content-Type header should include 'application/json' + And the JSON response should be an array + And response array should be empty + diff --git a/devops-service/features/image.feature b/devops-service/features/image.feature index b45e4bb..34fff8b 100644 --- a/devops-service/features/image.feature +++ b/devops-service/features/image.feature @@ -5,7 +5,7 @@ Feature: Manage images Then response should be '200' And the Content-Type header should include 'application/json' And the JSON response should be an array - And response should be JSON, images list: + And response array should contains elements like: """ [ { diff --git a/devops-service/features/step_definitions/http_queries_steps.rb b/devops-service/features/step_definitions/http_queries_steps.rb index 9065a88..fbc3d05 100644 --- a/devops-service/features/step_definitions/http_queries_steps.rb +++ b/devops-service/features/step_definitions/http_queries_steps.rb @@ -4,6 +4,7 @@ DEFAULT_HEADERS = { 'Accept' => 'application/json' } When(/^I send GET '(.*)' query$/) do |path| + puts path get(path, {}, DEFAULT_HEADERS) end diff --git a/devops-service/features/step_definitions/image_steps.rb b/devops-service/features/step_definitions/image_steps.rb index 4f55b66..40e48d1 100644 --- a/devops-service/features/step_definitions/image_steps.rb +++ b/devops-service/features/step_definitions/image_steps.rb @@ -23,6 +23,7 @@ Then(/^the JSON response should be a hash$/) do assert body.is_a?(Hash), "Body is not a hash" end +=begin Then(/^response should be JSON, images list:$/) do |string| src_image = JSON.parse(string).first image = JSON.parse(last_response.body).first @@ -30,6 +31,7 @@ Then(/^response should be JSON, images list:$/) do |string| assert image.key?(key), "Image has no key '#{key}'" end end +=end Then(/^response should be JSON, image object:$/) do |string| src_image = JSON.parse(string) diff --git a/devops-service/features/step_definitions/json_steps.rb b/devops-service/features/step_definitions/json_steps.rb new file mode 100644 index 0000000..f808249 --- /dev/null +++ b/devops-service/features/step_definitions/json_steps.rb @@ -0,0 +1,14 @@ +Then(/^response array should contains elements like:$/) do |string| + src = JSON.parse(string).first + array = JSON.parse(last_response.body) + array.each do |e| + src.each do |key, value| + assert e.key?(key), "Element #{e.inspect} has no key '#{key}'" + end + end +end + +Then(/^response array should be empty$/) do + array = JSON.parse(last_response.body) + assert array.empty?, "Array is not empty" +end diff --git a/devops-service/providers/ec2.rb b/devops-service/providers/ec2.rb index 8ed3b23..96dba38 100644 --- a/devops-service/providers/ec2.rb +++ b/devops-service/providers/ec2.rb @@ -182,6 +182,9 @@ module Provider end end + def compute + connection_compute(connection_options) + end private def convert_groups list res = {} @@ -231,10 +234,5 @@ module Provider end r end - - private - def compute - connection_compute(connection_options) - end end end diff --git a/devops-service/providers/openstack.rb b/devops-service/providers/openstack.rb index 97fa2eb..9a27102 100644 --- a/devops-service/providers/openstack.rb +++ b/devops-service/providers/openstack.rb @@ -182,6 +182,13 @@ module Provider return nil end + def compute + connection_compute(self.connection_options) + end + + def network + connection_network(self.connection_options) + end private def convert_groups list res = {} @@ -203,13 +210,5 @@ module Provider res end - def compute - connection_compute(self.connection_options) - end - - def network - connection_network(self.connection_options) - end - end end