def test_initialize_called(self): driver1 = Extension('mock_driver1', Mock(), None, Mock(native_bulk_support=True)) driver2 = Extension('mock_driver2', Mock(), None, Mock(native_bulk_support=True)) manager = SfcDriverManager.make_test_instance([driver1, driver2]) manager.initialize() driver1.obj.initialize.assert_called_once_with() driver2.obj.initialize.assert_called_once_with()
def _test_method_exception(self, method_name, expected_exc=sfc_exc.SfcDriverError): driver = Extension('mock_driver', Mock(), None, Mock(native_bulk_support=True)) mock_method = Mock(side_effect=sfc_exc.SfcException) setattr(driver.obj, method_name, mock_method) manager = SfcDriverManager.make_test_instance([driver]) mocked_context = Mock() self.assertRaises(expected_exc, getattr(manager, method_name), mocked_context)
def _test_method_called(self, method_name): driver1 = Extension('mock_driver1', Mock(), None, Mock(native_bulk_support=True)) driver2 = Extension('mock_driver2', Mock(), None, Mock(native_bulk_support=True)) manager = SfcDriverManager.make_test_instance([driver1, driver2]) mocked_context = Mock() getattr(manager, method_name)(mocked_context) getattr(driver1.obj, method_name).assert_called_once_with( mocked_context) getattr(driver2.obj, method_name).assert_called_once_with( mocked_context)
def _test_method_called(self, method_name): driver1 = Extension('mock_driver1', Mock(), None, Mock(native_bulk_support=True)) driver2 = Extension('mock_driver2', Mock(), None, Mock(native_bulk_support=True)) manager = SfcDriverManager.make_test_instance([driver1, driver2]) mocked_context = Mock() getattr(manager, method_name)(mocked_context) getattr(driver1.obj, method_name).assert_called_once_with(mocked_context) getattr(driver2.obj, method_name).assert_called_once_with(mocked_context)