Пример #1
0
 def test_api_class_error(self):
     api_class = mock.Mock(side_effect=RuntimeError())
     idl = mock.Mock()
     with testtools.ExpectedException(RuntimeError):
         with ovsdb_monitor.short_living_ovsdb_api(api_class, idl):
             # Make sure it never enter the api context
             raise Exception("API class instantiated but it should not")
Пример #2
0
 def test_context_error(self):
     api_class = mock.Mock()
     idl = mock.Mock()
     exc = RuntimeError()
     try:
         with ovsdb_monitor.short_living_ovsdb_api(api_class, idl) as api:
             self.assertEqual(api_class.return_value, api)
             raise exc
     except RuntimeError as re:
         self.assertIs(exc, re)
     api.ovsdb_connection.stop.assert_called_once_with()
Пример #3
0
 def test_context(self):
     api_class = mock.Mock()
     idl = mock.Mock()
     with ovsdb_monitor.short_living_ovsdb_api(api_class, idl) as api:
         self.assertEqual(api_class.return_value, api)
     api.ovsdb_connection.stop.assert_called_once_with()