Class: RHC::Rest::Mock::MockRestCartridge

Inherits:
Cartridge show all
Includes:
Helpers
Defined in:
lib/rhc/rest/mock.rb

Constant Summary

Constants inherited from Cartridge

Cartridge::HIDDEN_TAGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#challenge, #credentials_for, #define_exceptional_test_on_wizard, #empty_domains, #empty_keys, #empty_response_list, #example_allows_gear_sizes?, #example_allows_members?, #expect_authorization, #mock_alias_links, #mock_alias_response, #mock_api_with_authorizations, #mock_app_links, #mock_cart_links, #mock_cartridge_response, #mock_client_links, #mock_date_1, #mock_domain_links, #mock_gear_groups_response, #mock_href, #mock_key_links, #mock_pass, #mock_real_client_links, #mock_response_links, #mock_uri, #mock_user, #mock_user_auth, #mock_user_links, #new_authorization, #new_domain, #simple_carts, #simple_user, #stub_add_authorization, #stub_add_key, #stub_add_key_error, #stub_api, #stub_api_request, #stub_api_v12, #stub_application_cartridges, #stub_authorizations, #stub_create_domain, #stub_delete_authorization, #stub_delete_authorizations, #stub_mock_ssh_keys, #stub_no_domains, #stub_no_keys, #stub_one_application, #stub_one_domain, #stub_one_key, #stub_relative_application, #stub_simple_carts, #stub_update_key, #stub_user

Methods inherited from Cartridge

#<=>, #additional_gear_storage, #collocated_with, #connection_info, #custom?, #display_name, for_url, #gear_storage, #only_in_existing?, #only_in_new?, #property, #scalable?, #scaling, #shares_gears?, #short_name, #tags, #url_basename, #usage_rate?

Methods inherited from Base

#add_message, #has_param?, #link_href, #links, #rest_method, #supports?

Methods included from AttributesClass

#define_attr, #model_name

Methods included from Attributes

#attribute, #attributes, #attributes=, #clear_attribute

Constructor Details

#initialize(client, name, type, app = nil, tags = [], properties = [{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }], description = nil) ⇒ MockRestCartridge

Returns a new instance of MockRestCartridge.



932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/rhc/rest/mock.rb', line 932

def initialize(client, name, type, app=nil, tags=[], properties=[{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }], description=nil)
  super({}, client)
  @name = name
  @description = description || "Description of #{name}"
  @type = type
  @app = app
  @tags = tags
  @properties = properties.each(&:stringify_keys!)
  @status_messages = [{"message" => "started", "gear_id" => "123"}]
  @scales_from = 1
  @scales_to = 1
  @current_scale = 1
  @gear_profile = 'small'
  @additional_gear_storage = 5
  @usage_rate = 0.0
end

Instance Attribute Details

#usage_rateObject

Returns the value of attribute usage_rate.



930
931
932
# File 'lib/rhc/rest/mock.rb', line 930

def usage_rate
  @usage_rate
end

Instance Method Details

#destroyObject



949
950
951
# File 'lib/rhc/rest/mock.rb', line 949

def destroy
  @app.cartridges.delete self
end

#reloadObject



972
973
974
# File 'lib/rhc/rest/mock.rb', line 972

def reload
  @app
end

#restartObject



967
968
969
970
# File 'lib/rhc/rest/mock.rb', line 967

def restart
  @status_messages = [{"message" => "started", "gear_id" => "123"}]
  @app
end

#set_scales(values) ⇒ Object



976
977
978
979
980
981
# File 'lib/rhc/rest/mock.rb', line 976

def set_scales(values)
  values.delete_if{|k,v| v.nil? }
  @scales_from = values[:scales_from] if values[:scales_from]
  @scales_to = values[:scales_to] if values[:scales_to]
  self
end

#set_storage(values) ⇒ Object



983
984
985
986
# File 'lib/rhc/rest/mock.rb', line 983

def set_storage(values)
  @additional_gear_storage = values[:additional_gear_storage] if values[:additional_gear_storage]
  self
end

#startObject



957
958
959
960
# File 'lib/rhc/rest/mock.rb', line 957

def start
  @status_messages = [{"message" => "started", "gear_id" => "123"}]
  @app
end

#statusObject



953
954
955
# File 'lib/rhc/rest/mock.rb', line 953

def status
  @status_messages
end

#stopObject



962
963
964
965
# File 'lib/rhc/rest/mock.rb', line 962

def stop
  @status_messages = [{"message" => "stopped", "gear_id" => "123"}]
  @app
end