def test_all_locales_none(self): addon = None field_name = 'description' eq_(helpers.all_locales(addon, field_name), None) addon = Mock() field_name = 'description' del addon.description eq_(helpers.all_locales(addon, field_name), None)
def test_all_locales_empty(self): obj = TranslatedModel() obj.description = {"en-US": "There", "es": "Is No", "fr": ""} # Pretend the TranslateModel instance was saved to force Translation # objects to be saved. save_signal(sender=TranslatedModel, instance=obj) result = helpers.all_locales(obj, "description") assert u'<div class="trans" data-name="description">' in result assert u'<span lang="en-us">There</span>' in result assert u'<span lang="es">Is No</span>' in result assert u'<span lang="fr"></span>' in result result = helpers.all_locales(obj, "description", prettify_empty=True) assert u'<div class="trans" data-name="description">' in result assert u'<span lang="en-us">There</span>' in result assert u'<span lang="es">Is No</span>' in result assert u'<span class="empty" lang="fr">None</span>' in result
def test_all_locales_empty(self): obj = TranslatedModel() obj.description = {'en-US': 'There', 'es': 'Is No', 'fr': ''} # Pretend the TranslateModel instance was saved to force Translation # objects to be saved. save_signal(sender=TranslatedModel, instance=obj) result = helpers.all_locales(obj, 'description') assert u'<div class="trans" data-name="description">' in result assert u'<span lang="en-us">There</span>' in result assert u'<span lang="es">Is No</span>' in result assert u'<span lang="fr"></span>' in result result = helpers.all_locales(obj, 'description', prettify_empty=True) assert u'<div class="trans" data-name="description">' in result assert u'<span lang="en-us">There</span>' in result assert u'<span lang="es">Is No</span>' in result assert u'<span class="empty" lang="fr">None</span>' in result
def test_all_locales(self): obj = TranslatedModel() obj.description = { 'en-US': 'There', 'es': 'Is No', 'fr': 'Spoon' } # Pretend the TranslateModel instance was saved to force Translation # objects to be saved. save_signal(sender=TranslatedModel, instance=obj) result = helpers.all_locales(obj, 'description') assert u'<div class="trans" data-name="description">' in result assert u'<span lang="en-us">There</span>' in result assert u'<span lang="es">Is No</span>' in result assert u'<span lang="fr">Spoon</span>' in result