Allow __new__ method to accept extra arguments
L3_NAT_dbonly_mixin accepts no extra arguments, but some subclasses do want to be able to accept them. Change-Id: I069215c4f3031661b7ce2c692dcf4cce1bd29b6c Closes-bug: #1657412
This commit is contained in:
parent
78189ef987
commit
e862d28068
|
@ -87,8 +87,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||||
|
|
||||||
_fip_qos = None
|
_fip_qos = None
|
||||||
|
|
||||||
def __new__(cls):
|
def __new__(cls, *args, **kwargs):
|
||||||
inst = super(L3_NAT_dbonly_mixin, cls).__new__(cls)
|
inst = super(L3_NAT_dbonly_mixin, cls).__new__(cls, *args, **kwargs)
|
||||||
inst._start_janitor()
|
inst._start_janitor()
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,16 @@ class TestL3_NAT_dbonly_mixin(base.BaseTestCase):
|
||||||
filtered = l3_db.L3_NAT_dbonly_mixin._each_port_having_fixed_ips(None)
|
filtered = l3_db.L3_NAT_dbonly_mixin._each_port_having_fixed_ips(None)
|
||||||
self.assertEqual([], list(filtered))
|
self.assertEqual([], list(filtered))
|
||||||
|
|
||||||
|
def test__new__passes_args(self):
|
||||||
|
class T(l3_db.L3_NAT_db_mixin):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.args = args
|
||||||
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
t = T(1, 2, a=3)
|
||||||
|
self.assertEqual((1, 2), t.args)
|
||||||
|
self.assertEqual({'a': 3}, t.kwargs)
|
||||||
|
|
||||||
def test__each_port_having_fixed_ips(self):
|
def test__each_port_having_fixed_ips(self):
|
||||||
"""Basic test that ports without fixed ips are filtered out"""
|
"""Basic test that ports without fixed ips are filtered out"""
|
||||||
ports = [{'id': 'a', 'fixed_ips': [mock.sentinel.fixedip]},
|
ports = [{'id': 'a', 'fixed_ips': [mock.sentinel.fixedip]},
|
||||||
|
|
Loading…
Reference in New Issue