Merge "Remove mox in sec group test and functional tests"
This commit is contained in:
@@ -116,7 +116,7 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios,
|
||||
if not self.USE_NEUTRON:
|
||||
# self.network is only setup if USE_NEUTRON=False
|
||||
self.useFixture(test.SampleNetworks(host=self.network.host))
|
||||
fake_network.stub_compute_with_ips(self.stubs)
|
||||
fake_network.stub_compute_with_ips(self)
|
||||
self.useFixture(fixtures.SpawnIsSynchronousFixture())
|
||||
# this is used to generate sample docs
|
||||
self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
|
||||
|
||||
@@ -377,15 +377,16 @@ class TestSecurityGroupsV21(test.TestCase):
|
||||
|
||||
expected = {'security_groups': [expected]}
|
||||
|
||||
def return_security_groups(context, project, search_opts):
|
||||
return [security_group_db(sg) for sg in groups]
|
||||
|
||||
self.stubs.Set(self.controller.security_group_api, 'list',
|
||||
return_security_groups)
|
||||
|
||||
res_dict = self.controller.index(self.req)
|
||||
with mock.patch.object(
|
||||
self.controller.security_group_api, 'list',
|
||||
return_value=[
|
||||
security_group_db(
|
||||
secgroup) for secgroup in groups]) as mock_list:
|
||||
res_dict = self.controller.index(self.req)
|
||||
|
||||
self.assertEqual(res_dict, expected)
|
||||
mock_list.assert_called_once_with(self.req.environ['nova.context'],
|
||||
project='fake', search_opts={})
|
||||
|
||||
def test_get_security_group_list_all_tenants(self):
|
||||
all_groups = []
|
||||
|
||||
@@ -386,7 +386,7 @@ def unset_stub_network_methods(test):
|
||||
_real_functions[name])
|
||||
|
||||
|
||||
def stub_compute_with_ips(stubs):
|
||||
def stub_compute_with_ips(test):
|
||||
orig_get = compute_api.API.get
|
||||
orig_get_all = compute_api.API.get_all
|
||||
orig_create = compute_api.API.create
|
||||
@@ -403,10 +403,11 @@ def stub_compute_with_ips(stubs):
|
||||
def fake_pci_device_get_by_addr(context, node_id, dev_addr):
|
||||
return test_pci_device.fake_db_dev
|
||||
|
||||
stubs.Set(db, 'pci_device_get_by_addr', fake_pci_device_get_by_addr)
|
||||
stubs.Set(compute_api.API, 'get', fake_get)
|
||||
stubs.Set(compute_api.API, 'get_all', fake_get_all)
|
||||
stubs.Set(compute_api.API, 'create', fake_create)
|
||||
test.stub_out('nova.db.pci_device_get_by_addr',
|
||||
fake_pci_device_get_by_addr)
|
||||
test.stub_out('nova.compute.api.API.get', fake_get)
|
||||
test.stub_out('nova.compute.api.API.get_all', fake_get_all)
|
||||
test.stub_out('nova.compute.api.API.create', fake_create)
|
||||
|
||||
|
||||
def _get_fake_cache():
|
||||
|
||||
Reference in New Issue
Block a user