# File lib/rhc/rest/mock.rb, line 423 def initialize(config=RHC::Config) obj = self if RHC::Rest::Client.respond_to?(:stub) RHC::Rest::Client.stub(:new) { obj } else RHC::Rest::Client.instance_eval do @obj = obj def new(*args) @obj end end end @domains = [] @user = MockRestUser.new(client, config.username) @api = MockRestApi.new(client, config) end
# File lib/rhc/rest/mock.rb, line 463 def add_domain(id) d = MockRestDomain.new(self, id) @domains << d d end
# File lib/rhc/rest/mock.rb, line 473 def add_key(name, type, content) @user.add_key(name, type, content) end
# File lib/rhc/rest/mock.rb, line 440 def api @api end
# File lib/rhc/rest/mock.rb, line 452 def cartridges [MockRestCartridge.new(self, "mock_cart-1", "embedded"), # code should sort this to be after standalone MockRestCartridge.new(self, "mock_standalone_cart-1", "standalone"), MockRestCartridge.new(self, "mock_standalone_cart-2", "standalone"), MockRestCartridge.new(self, "mock_unique_standalone_cart-1", "standalone"), MockRestCartridge.new(self, "jenkins-1.4", "standalone"), MockRestCartridge.new(self, "mock_cart-2", "embedded"), MockRestCartridge.new(self, "unique_mock_cart-1", "embedded"), MockRestCartridge.new(self, "jenkins-client-1.4", "embedded")] end
# File lib/rhc/rest/mock.rb, line 477 def delete_key(name) @user.keys.delete_if { |key| key.name == name } end
# File lib/rhc/rest/mock.rb, line 448 def domains @domains end
Need to mock this since we are not registering HTTP requests when adding apps to the mock domain
# File lib/rhc/rest/mock.rb, line 482 def find_application(domain, name, options = {}) find_domain(domain).applications.each do |app| return app if app.name.downcase == name.downcase end raise RHC::Rest::ApplicationNotFoundException.new("Application #{name} does not exist") end
# File lib/rhc/rest/mock.rb, line 490 def find_application_gear_groups(domain, name, options = {}) find_domain(domain).applications.each do |app| return app.gear_groups if app.name.downcase == name.downcase end raise RHC::Rest::ApplicationNotFoundException.new("Application #{name} does not exist") end
# File lib/rhc/rest/mock.rb, line 430 def new(*args) @obj end
# File lib/rhc/rest/mock.rb, line 469 def sshkeys @user.keys end
# File lib/rhc/rest/mock.rb, line 444 def user @user end