Ejemplo n.º 1
0
    def test_create_from_translation_with_missing_msgid_raises_error(self):
        translatable = OrganizationBuilder().with_id('test_create_from_translation_with_missing_msgid_raises_error_id').build()

        base_translation = add_base_translation(
            translatable, name=''
        )
        translation = add_translation(
            translatable, 'fr', name='translation_name_msgstr'
        )

        with self.assertRaises(MissingMsgidError):
            TranslatableString.from_translation(translation, 'name')
Ejemplo n.º 2
0
    def test_create_from_translation(self):
        translatable = OrganizationBuilder().with_id('test_create_from_translation_id').build()

        base_translation = add_base_translation(
            translatable, name='translation_name_msgid'
        )
        translation = add_translation(
            translatable, 'fr', name='translation_name_msgstr'
        )

        translatable_string = TranslatableString.from_translation(translation, 'name')

        self.assertEqual(translatable_string._instance, translatable)
        self.assertEqual(translatable_string._field_id, 'name')
        self.assertEqual(translatable_string._source_str, 'translation_name_msgid')
        self.assertEqual(translatable_string._translated_str, 'translation_name_msgstr')