14
14
15
15
from unittest import mock
16
16
17
+ from neutron_lib .callbacks import events
18
+ from neutron_lib .callbacks import registry
19
+ from neutron_lib .callbacks import resources
20
+ from neutron_lib import constants as const
21
+ from neutron_lib .plugins import constants as plugin_constants
22
+ from oslo_utils import uuidutils
23
+ from ovsdbapp import constants as ovsdbapp_const
24
+
17
25
from neutron .common .ovn import constants as ovn_const
26
+ from neutron .common .ovn import exceptions as ovn_exc
27
+ from neutron .common .ovn import utils as ovn_utils
28
+ from neutron .conf .plugins .ml2 .drivers .ovn import ovn_conf
18
29
from neutron .objects import port_forwarding as port_forwarding_obj
19
30
from neutron .services .portforwarding .constants import PORT_FORWARDING
20
31
from neutron .services .portforwarding .constants import PORT_FORWARDING_PLUGIN
21
32
from neutron .services .portforwarding .drivers .ovn import driver \
22
33
as port_forwarding
23
34
from neutron .tests import base
24
35
from neutron .tests .unit import fake_resources
25
- from neutron_lib .callbacks import events
26
- from neutron_lib .callbacks import registry
27
- from neutron_lib .callbacks import resources
28
- from neutron_lib import constants as const
29
- from neutron_lib .plugins import constants as plugin_constants
30
- from oslo_utils import uuidutils
31
- from ovsdbapp import constants as ovsdbapp_const
32
36
33
37
34
38
class TestOVNPortForwardingBase (base .BaseTestCase ):
@@ -450,6 +454,7 @@ def test_port_forwarding_deleted(self, m_info):
450
454
class TestOVNPortForwarding (TestOVNPortForwardingBase ):
451
455
def setUp (self ):
452
456
super (TestOVNPortForwarding , self ).setUp ()
457
+ ovn_conf .register_opts ()
453
458
self .pf_plugin = mock .Mock ()
454
459
self .handler = mock .Mock ()
455
460
get_mock_pf_plugin = lambda alias : self .pf_plugin if (
@@ -475,6 +480,25 @@ def test_init(self):
475
480
self .assertEqual (self ._ovn_pf ._handler , self .handler )
476
481
self .assertEqual (self ._ovn_pf ._pf_plugin , self .pf_plugin )
477
482
483
+ def test__validate_configuration_ok (self ):
484
+ with mock .patch .object (
485
+ port_forwarding .LOG , "warning" ) as mock_warning , \
486
+ mock .patch .object (ovn_utils ,
487
+ "validate_port_forwarding_configuration" ):
488
+
489
+ self ._ovn_pf ._validate_configuration ()
490
+ mock_warning .assert_not_called ()
491
+
492
+ def test__validate_configuration_wrong (self ):
493
+ with mock .patch .object (
494
+ port_forwarding .LOG , "warning" ) as mock_warning , \
495
+ mock .patch .object (
496
+ ovn_utils ,
497
+ "validate_port_forwarding_configuration" ,
498
+ side_effect = ovn_exc .InvalidPortForwardingConfiguration ):
499
+ self ._ovn_pf ._validate_configuration ()
500
+ mock_warning .assert_called_once_with (mock .ANY )
501
+
478
502
def test_register (self ):
479
503
with mock .patch .object (registry , 'subscribe' ) as mock_subscribe :
480
504
self ._ovn_pf .register (mock .ANY , mock .ANY , mock .Mock ())
0 commit comments