class RHC::Rest::Mock::MockRestClient

Public Class Methods

new(config=RHC::Config, version=1.0) click to toggle source
# File lib/rhc/rest/mock.rb, line 459
def initialize(config=RHC::Config, version=1.0)
  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)
  @version = version
end

Public Instance Methods

add_domain(id) click to toggle source
# File lib/rhc/rest/mock.rb, line 511
def add_domain(id)
  d = MockRestDomain.new(self, id)
  @domains << d
  d
end
add_key(name, type, content) click to toggle source
# File lib/rhc/rest/mock.rb, line 521
def add_key(name, type, content)
  @user.add_key(name, type, content)
end
api() click to toggle source
# File lib/rhc/rest/mock.rb, line 477
def api
  @api
end
api_version_negotiated() click to toggle source
# File lib/rhc/rest/mock.rb, line 489
def api_version_negotiated
  @version
end
cartridges() click to toggle source
# File lib/rhc/rest/mock.rb, line 493
def cartridges
  premium_embedded = MockRestCartridge.new(self, "premium_cart", "embedded")
  premium_embedded.usage_rate = 0.05

  [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"),
   MockRestCartridge.new(self, "embcart-1", "embedded"),
   MockRestCartridge.new(self, "embcart-2", "embedded"),
   premium_embedded
  ]
end
delete_key(name) click to toggle source
# File lib/rhc/rest/mock.rb, line 525
def delete_key(name)
  @user.keys.delete_if { |key| key.name == name }
end
domains() click to toggle source
# File lib/rhc/rest/mock.rb, line 485
def domains
  @domains
end
find_application(domain, name, options = {}) click to toggle source

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 530
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
find_application_gear_groups(domain, name, options = {}) click to toggle source
# File lib/rhc/rest/mock.rb, line 538
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
new(*args) click to toggle source
# File lib/rhc/rest/mock.rb, line 466
def new(*args)
  @obj
end
sshkeys() click to toggle source
# File lib/rhc/rest/mock.rb, line 517
def sshkeys
  @user.keys
end
user() click to toggle source
# File lib/rhc/rest/mock.rb, line 481
def user
  @user
end