def test_should_return_message_id_if_translation_is_false(self): with patch('builtins.open', new_callable=mock_open()): with patch('frontstage.i18n.translations.load', MagicMock()) as m_load: m_load.return_value = self.example_translations instance = Translate('filename') output = instance.translate('message2', 'en') self.assertEqual(output, 'message2')
def test_should_return_message_id_if_translation_is_false(self): with patch("builtins.open", new_callable=mock_open()): with patch("frontstage.i18n.translations.load", MagicMock()) as m_load: m_load.return_value = self.example_translations instance = Translate("filename") output = instance.translate("message2", "en") self.assertEqual(output, "message2")
def test_should_use_passed_locale(self): with patch('builtins.open', new_callable=mock_open()): with patch('frontstage.i18n.translations.load', MagicMock()) as m_load: m_load.return_value = self.example_translations instance = Translate('filename') output = instance.translate('message1', 'fr_FR') self.assertEqual(output, 'message_1_revenir')
def test_should_use_passed_locale(self): with patch("builtins.open", new_callable=mock_open()): with patch("frontstage.i18n.translations.load", MagicMock()) as m_load: m_load.return_value = self.example_translations instance = Translate("filename") output = instance.translate("message1", "fr_FR") self.assertEqual(output, "message_1_revenir")
def test_should_message_id_if_passed_locale_exists_but_doesnt_contain_message_id( self): with patch('builtins.open', new_callable=mock_open()): with patch('frontstage.i18n.translations.load', MagicMock()) as m_load: m_load.return_value = self.example_translations instance = Translate('filename') output = instance.translate('message3', 'en') self.assertEqual(output, 'message3')