def setUp(self): super(NetworksJsonTests, self).setUp() fake_network_api = test_networks.FakeNetworkAPI() self.stub_out("nova.network.api.API.get_all", fake_network_api.get_all) self.stub_out("nova.network.api.API.get", fake_network_api.get) self.stub_out("nova.network.api.API.associate", fake_network_api.associate) self.stub_out("nova.network.api.API.delete", fake_network_api.delete) self.stub_out("nova.network.api.API.create", fake_network_api.create) self.stub_out("nova.network.api.API.add_network_to_project", fake_network_api.add_network_to_project)
def setUp(self): super(NetworksJsonTests, self).setUp() fake_network_api = test_networks.FakeNetworkAPI() self.stubs.Set(network_api.API, "get_all", fake_network_api.get_all) self.stubs.Set(network_api.API, "get", fake_network_api.get) self.stubs.Set(network_api.API, "associate", fake_network_api.associate) self.stubs.Set(network_api.API, "delete", fake_network_api.delete) self.stubs.Set(network_api.API, "create", fake_network_api.create) self.stubs.Set(network_api.API, "add_network_to_project", fake_network_api.add_network_to_project)
def _fixtures_passthrough(method_name): # This compensates for how fixtures 3.x handles the signatures of # MonkeyPatched functions vs fixtures < 3.x. In fixtures 3 if a bound # method is patched in for a bound method then both objects will be passed # in when called. This means the patch method should have the signature of # (self, targetself, *args, **kwargs). However that will not work for # fixtures < 3. This method captures self from the call point and discards # it since it's not needed. fake_network_api = test_networks.FakeNetworkAPI() method = getattr(fake_network_api, method_name) def call(self, *args, **kwargs): # self is the nova.network.api.API object that has been patched # method is bound to FakeNetworkAPI so that will be passed in as self return method(*args, **kwargs) return call