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)
Beispiel #2
0
    def test_all_locales_none(self):
        addon = None
        field_name = 'description'
        assert helpers.all_locales(addon, field_name) is None

        addon = Mock()
        field_name = 'description'
        del addon.description
        assert helpers.all_locales(addon, field_name) is None
Beispiel #3
0
    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_none(self):
        addon = None
        field_name = 'description'
        assert helpers.all_locales(addon, field_name) is None

        addon = Mock()
        field_name = 'description'
        del addon.description
        assert helpers.all_locales(addon, field_name) is 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
Beispiel #6
0
    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