def test_info_is_passed_to_chained_translators(): translator = mock.MagicMock(spec=TranslatorBase) t = ChainedTranslator(translator) t.translate("fake_package", "fake_into") translator.translate.assert_called_with("fake_package", into="fake_into")
def test_info_is_passed_to_chained_translators(): translator = mock.MagicMock(spec=TranslatorBase) t = ChainedTranslator(translator) t.translate("fake_package", "fake_into") translator.translate.assert_called_with("fake_package", into="fake_into")
def test_chained_translator_short_circuit_translate(): initial_empty_translator = mock.MagicMock(spec=TranslatorBase) initial_empty_translator.translate.return_value = None translator_with_value = mock.MagicMock(spec=TranslatorBase) translator_with_value.translate.return_value = "fake_success" translator_after_value = mock.MagicMock(spec=TranslatorBase) t = ChainedTranslator(initial_empty_translator, translator_with_value, translator_after_value) result = t.translate("fake_package", "fake_into") assert result == "fake_success" assert initial_empty_translator.translate.called assert translator_with_value.translate.called assert not translator_after_value.translate.called