Merge "Remove mox in test_availability_zone.py"
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import datetime
|
||||
|
||||
import iso8601
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.api.openstack.compute import availability_zone as az_v21
|
||||
@@ -25,7 +26,6 @@ from nova.compute import api as compute_api
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import servicegroup
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit.image import fake
|
||||
@@ -33,6 +33,8 @@ from nova.tests.unit import matchers
|
||||
from nova.tests.unit.objects import test_service
|
||||
from nova.tests import uuidsentinel
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
FAKE_UUID = fakes.FAKE_UUID
|
||||
|
||||
|
||||
@@ -76,21 +78,6 @@ def fake_service_get_all(context, disabled=None):
|
||||
"fake_host-2", False)]
|
||||
|
||||
|
||||
def fake_service_is_up(self, service):
|
||||
return service['binary'] != u"nova-network"
|
||||
|
||||
|
||||
def fake_set_availability_zones(context, services):
|
||||
return services
|
||||
|
||||
|
||||
def fake_get_availability_zones(context):
|
||||
return ['nova'], []
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class AvailabilityZoneApiTestV21(test.NoDBTestCase):
|
||||
availability_zone = az_v21
|
||||
|
||||
@@ -99,9 +86,10 @@ class AvailabilityZoneApiTestV21(test.NoDBTestCase):
|
||||
availability_zones.reset_cache()
|
||||
fakes.stub_out_nw_api(self)
|
||||
self.stub_out('nova.db.service_get_all', fake_service_get_all)
|
||||
self.stubs.Set(availability_zones, 'set_availability_zones',
|
||||
fake_set_availability_zones)
|
||||
self.stubs.Set(servicegroup.API, 'service_is_up', fake_service_is_up)
|
||||
self.stub_out('nova.availability_zones.set_availability_zones',
|
||||
lambda c, services: services)
|
||||
self.stub_out('nova.servicegroup.API.service_is_up',
|
||||
lambda s, service: service['binary'] != u"nova-network")
|
||||
self.controller = self.availability_zone.AvailabilityZoneController()
|
||||
self.req = fakes.HTTPRequest.blank('')
|
||||
|
||||
@@ -161,14 +149,13 @@ class AvailabilityZoneApiTestV21(test.NoDBTestCase):
|
||||
'hosts': None}]
|
||||
self.assertEqual(expected, zones)
|
||||
|
||||
def test_availability_zone_detail_no_services(self):
|
||||
@mock.patch.object(availability_zones, 'get_availability_zones',
|
||||
return_value=[['nova'], []])
|
||||
def test_availability_zone_detail_no_services(self, mock_get_az):
|
||||
expected_response = {'availabilityZoneInfo':
|
||||
[{'zoneState': {'available': True},
|
||||
'hosts': {},
|
||||
'zoneName': 'nova'}]}
|
||||
self.stubs.Set(availability_zones, 'get_availability_zones',
|
||||
fake_get_availability_zones)
|
||||
|
||||
resp_dict = self.controller.detail(self.req)
|
||||
|
||||
self.assertThat(resp_dict,
|
||||
@@ -208,7 +195,7 @@ class ServersControllerCreateTestV21(test.TestCase):
|
||||
return old_create(*args, **kwargs)
|
||||
|
||||
old_create = compute_api.API.create
|
||||
self.stubs.Set(compute_api.API, 'create', create)
|
||||
self.stub_out('nova.compute.api.API.create', create)
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
flavor_ref = ('http://localhost' + self.base_url + 'flavors/3')
|
||||
body = {
|
||||
|
Reference in New Issue
Block a user