Re-home unit tests
Move them to their respective test_*.py files. Created base.py to hold the parent class common to all sub-tests. Change-Id: I4f8466ceb36356e0d80cdcfe1e6e2c5884c1f567
This commit is contained in:
parent
178dbd3fee
commit
b1a457f35f
51
ovn_octavia_provider/tests/unit/base.py
Normal file
51
ovn_octavia_provider/tests/unit/base.py
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
from unittest import mock
|
||||
|
||||
from neutron.tests import base
|
||||
from octavia_lib.api.drivers import driver_lib
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
|
||||
class TestOvnOctaviaBase(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOvnOctaviaBase, self).setUp()
|
||||
self.listener_id = uuidutils.generate_uuid()
|
||||
self.loadbalancer_id = uuidutils.generate_uuid()
|
||||
self.pool_id = uuidutils.generate_uuid()
|
||||
self.member_id = uuidutils.generate_uuid()
|
||||
self.member_subnet_id = uuidutils.generate_uuid()
|
||||
self.member_port = '1010'
|
||||
self.member_pool_id = self.pool_id
|
||||
self.member_address = '192.168.2.149'
|
||||
self.port1_id = uuidutils.generate_uuid()
|
||||
self.port2_id = uuidutils.generate_uuid()
|
||||
self.project_id = uuidutils.generate_uuid()
|
||||
self.vip_network_id = uuidutils.generate_uuid()
|
||||
self.vip_port_id = uuidutils.generate_uuid()
|
||||
self.vip_subnet_id = uuidutils.generate_uuid()
|
||||
ovn_nb_idl = mock.patch(
|
||||
'ovn_octavia_provider.ovsdb.impl_idl_ovn.OvnNbIdlForLb')
|
||||
self.mock_ovn_nb_idl = ovn_nb_idl.start()
|
||||
self.member_address = '192.168.2.149'
|
||||
self.vip_address = '192.148.210.109'
|
||||
self.vip_dict = {'vip_network_id': uuidutils.generate_uuid(),
|
||||
'vip_subnet_id': uuidutils.generate_uuid()}
|
||||
self.vip_output = {'vip_network_id': self.vip_dict['vip_network_id'],
|
||||
'vip_subnet_id': self.vip_dict['vip_subnet_id']}
|
||||
mock.patch(
|
||||
'ovsdbapp.backend.ovs_idl.idlutils.get_schema_helper').start()
|
||||
mock.patch.object(
|
||||
driver_lib.DriverLibrary, '_check_for_socket_ready').start()
|
27
ovn_octavia_provider/tests/unit/test_agent.py
Normal file
27
ovn_octavia_provider/tests/unit/test_agent.py
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
from unittest import mock
|
||||
|
||||
from ovn_octavia_provider import agent as ovn_agent
|
||||
from ovn_octavia_provider.tests.unit import base as ovn_base
|
||||
|
||||
|
||||
class TestOvnProviderAgent(ovn_base.TestOvnOctaviaBase):
|
||||
|
||||
def test_exit(self):
|
||||
mock_exit_event = mock.MagicMock()
|
||||
mock_exit_event.is_set.side_effect = [False, False, False, False, True]
|
||||
ovn_agent.OvnProviderAgent(mock_exit_event)
|
||||
self.assertEqual(1, mock_exit_event.wait.call_count)
|
||||
self.assertEqual(2, self.mock_ovn_nb_idl.call_count)
|
File diff suppressed because it is too large
Load Diff
2296
ovn_octavia_provider/tests/unit/test_helper.py
Normal file
2296
ovn_octavia_provider/tests/unit/test_helper.py
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user