Mock out poller in ovsdb unittests

The second thread running in ovsdb connection crashed due to not passing
file descriptor to poller. This patch mocks out the poller as it's not
used in the tests to avoid false tracebacks in the logs.

Change-Id: I62e87e3248d176e5db7fe57bfb4467176ba05392
Closes-Bug: 1583069
This commit is contained in:
Jakub Libosvar 2016-05-18 09:36:13 +00:00
parent 0eed94a777
commit 99f2224e6b
1 changed files with 5 additions and 1 deletions

View File

@ -12,11 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import eventlet
import mock
import unittest2
try:
from ovs.db import idl
from ovs import poller
except ImportError:
raise unittest2.SkipTest(
"Skip test since ovs requirement for PY3 doesn't support yet.")
@ -40,7 +42,9 @@ class TestOVSNativeConnection(base.BaseTestCase):
gsh.return_value = helper = mock.Mock()
self.connection = connection.Connection(
mock.Mock(), mock.Mock(), mock.Mock())
self.connection.start(table_name_list=table_name_list)
with mock.patch.object(poller, 'Poller') as poller_mock:
poller_mock.return_value.block.side_effect = eventlet.sleep
self.connection.start(table_name_list=table_name_list)
reg_all_called = table_name_list is None
reg_table_called = table_name_list is not None
self.assertEqual(reg_all_called, helper.register_all.called)