Re-home MockedLB to tests.unit.fakes
Renamed to tests.unit.fakes.FakeLB Change-Id: I1d18634f48c29ab3c07c244cc8826bdb987afdc4
This commit is contained in:
parent
c8116dd640
commit
94daec2d4a
@ -15,6 +15,7 @@
|
|||||||
import copy
|
import copy
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
from octavia_lib.api.drivers import data_models
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from ovn_octavia_provider.common import constants
|
from ovn_octavia_provider.common import constants
|
||||||
@ -290,3 +291,14 @@ class FakePort(object):
|
|||||||
|
|
||||||
return FakeResource(info=copy.deepcopy(port_attrs),
|
return FakeResource(info=copy.deepcopy(port_attrs),
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeLB(data_models.LoadBalancer):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.external_ids = kwargs.pop('ext_ids')
|
||||||
|
self.uuid = kwargs.pop('uuid')
|
||||||
|
super(FakeLB, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
# Required for Python3, not for Python2
|
||||||
|
return self.__sizeof__()
|
||||||
|
@ -36,18 +36,6 @@ schema_files = {
|
|||||||
'schemas', 'ovn-nb.ovsschema')}
|
'schemas', 'ovn-nb.ovsschema')}
|
||||||
|
|
||||||
|
|
||||||
# TODO(mjozefcz): Move it to unittest fakes.
|
|
||||||
class MockedLB(data_models.LoadBalancer):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.external_ids = kwargs.pop('ext_ids')
|
|
||||||
self.uuid = kwargs.pop('uuid')
|
|
||||||
super(MockedLB, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
# Required for Python3, not for Python2
|
|
||||||
return self.__sizeof__()
|
|
||||||
|
|
||||||
|
|
||||||
class TestOvnNbIdlForLb(base.BaseTestCase):
|
class TestOvnNbIdlForLb(base.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestOvnNbIdlForLb, self).setUp()
|
super(TestOvnNbIdlForLb, self).setUp()
|
||||||
@ -752,7 +740,7 @@ class TestOvnProviderHelper(TestOvnOctaviaBase):
|
|||||||
# NOTE(mjozefcz): Create foo router and network.
|
# NOTE(mjozefcz): Create foo router and network.
|
||||||
net_id = uuidutils.generate_uuid()
|
net_id = uuidutils.generate_uuid()
|
||||||
router_id = uuidutils.generate_uuid()
|
router_id = uuidutils.generate_uuid()
|
||||||
self.ref_lb1 = MockedLB(
|
self.ref_lb1 = fakes.FakeLB(
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
admin_state_up=True,
|
admin_state_up=True,
|
||||||
listeners=[],
|
listeners=[],
|
||||||
@ -765,7 +753,7 @@ class TestOvnProviderHelper(TestOvnOctaviaBase):
|
|||||||
ovn_const.LB_EXT_IDS_LR_REF_KEY: "neutron-%s" % net_id,
|
ovn_const.LB_EXT_IDS_LR_REF_KEY: "neutron-%s" % net_id,
|
||||||
ovn_const.LB_EXT_IDS_LS_REFS_KEY:
|
ovn_const.LB_EXT_IDS_LS_REFS_KEY:
|
||||||
'{\"neutron-%s\": 1}' % net_id})
|
'{\"neutron-%s\": 1}' % net_id})
|
||||||
self.ref_lb2 = MockedLB(
|
self.ref_lb2 = fakes.FakeLB(
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
admin_state_up=True,
|
admin_state_up=True,
|
||||||
listeners=[],
|
listeners=[],
|
||||||
|
Loading…
Reference in New Issue
Block a user