Esempio n. 1
0
    def test_with_locale(self):
        """
        If the request has a set locale, the form should only accept banners
        available in that locale.
        """
        fr_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=fr_banner, locale='fr')
        en_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=en_banner, locale='en-us')

        form = self.form('fr', {'text': 'asdf', 'banner': fr_banner.id})
        ok_(form.is_valid())

        form = self.form('fr', {'text': 'asdf', 'banner': en_banner.id})
        ok_(not form.is_valid())
Esempio n. 2
0
    def test_with_locale(self):
        """
        If the request has a set locale, the form should only accept banners
        available in that locale.
        """
        fr_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=fr_banner, locale='fr')
        en_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=en_banner, locale='en-us')

        form = self.form('fr', {'text': 'asdf', 'banner': fr_banner.id})
        ok_(form.is_valid())

        form = self.form('fr', {'text': 'asdf', 'banner': en_banner.id})
        ok_(not form.is_valid())
Esempio n. 3
0
    def test_no_locale(self):
        """
        If the request has no set locale, the form should accept any banner in
        any locale.
        """
        fr_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=fr_banner, locale='fr')
        en_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=en_banner, locale='en-us')

        form = self.form(None, {'text': 'asdf', 'banner': fr_banner.id})
        ok_(form.is_valid())

        form = self.form(None, {'text': 'asdf', 'banner': en_banner.id})
        ok_(form.is_valid())
Esempio n. 4
0
    def test_no_locale(self):
        """
        If the request has no set locale, the form should accept any banner in
        any locale.
        """
        fr_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=fr_banner, locale='fr')
        en_banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=en_banner, locale='en-us')

        form = self.form(None, {'text': 'asdf', 'banner': fr_banner.id})
        ok_(form.is_valid())

        form = self.form(None, {'text': 'asdf', 'banner': en_banner.id})
        ok_(form.is_valid())
Esempio n. 5
0
 def test_image_for_locale_no_locale(self):
     """
     If a banner is not available in the requested locale, return the default
     image.
     """
     banner = FacebookBannerFactory.create(image='test')
     ok_(banner.image_for_locale('es').name.endswith('test'))
Esempio n. 6
0
 def test_image_for_locale_no_locale(self):
     """
     If a banner is not available in the requested locale, return the default
     image.
     """
     banner = FacebookBannerFactory.create(image='test')
     ok_(banner.image_for_locale('es').name.endswith('test'))
Esempio n. 7
0
 def test_notify_new_instance(self):
     """
     If the instance being saved is new, no notification should be created.
     """
     user = FacebookUserFactory.create()
     banner = FacebookBannerFactory.create()
     instance = FacebookBannerInstanceFactory(user=user, banner=banner)
     instance.save()
     eq_(user.appnotification_set.exists(), False)
Esempio n. 8
0
 def test_image_for_locale_blank_default(self):
     """
     If a banner is available in the requested locale but the image is blank,
     return the default image.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner, locale='es',
                                        image='')
     ok_(banner.image_for_locale('es').name.endswith('banner'))
Esempio n. 9
0
 def test_image_for_locale_found(self):
     """
     If the banner is available in the requested locale, return the image for
     that locale.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner, locale='pt-BR',
                                        image='locale')
     ok_(banner.image_for_locale('pt-BR').name.endswith('locale'))
Esempio n. 10
0
 def test_notify_new_instance(self):
     """
     If the instance being saved is new, no notification should be created.
     """
     user = FacebookUserFactory.create()
     banner = FacebookBannerFactory.create()
     instance = FacebookBannerInstanceFactory(user=user, banner=banner)
     instance.save()
     eq_(user.appnotification_set.exists(), False)
Esempio n. 11
0
 def test_image_for_locale_fallback(self):
     """
     If the banner is available in a certain language and the requested
     locale is a subset of that language that isn't available, return the
     image for the fallback language.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner, locale='de',
                                        image='locale')
     ok_(banner.image_for_locale('de-ch').name.endswith('locale'))
Esempio n. 12
0
 def test_image_for_locale_blank_default(self):
     """
     If a banner is available in the requested locale but the image is blank,
     return the default image.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner,
                                        locale='es',
                                        image='')
     ok_(banner.image_for_locale('es').name.endswith('banner'))
Esempio n. 13
0
 def test_image_for_locale_found(self):
     """
     If the banner is available in the requested locale, return the image for
     that locale.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner,
                                        locale='pt-BR',
                                        image='locale')
     ok_(banner.image_for_locale('pt-BR').name.endswith('locale'))
Esempio n. 14
0
 def test_image_for_locale_fallback(self):
     """
     If the banner is available in a certain language and the requested
     locale is a subset of that language that isn't available, return the
     image for the fallback language.
     """
     banner = FacebookBannerFactory.create(image='banner')
     FacebookBannerLocaleFactory.create(banner=banner,
                                        locale='de',
                                        image='locale')
     ok_(banner.image_for_locale('de-ch').name.endswith('locale'))
Esempio n. 15
0
    def test_similar_locales(self):
        """
        Regression test for a bug where a user in the de locale would get a
        banner choice for each de locale (de, de-at, de-ch, de-de), causing
        duplicate choices and form processing errors.
        """
        banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=banner, locale='de')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-at')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-ch')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-de')

        form = self.form('de')
        eq_(len(form.fields['banner'].choices), 1)
Esempio n. 16
0
    def test_similar_locales(self):
        """
        Regression test for a bug where a user in the de locale would get a
        banner choice for each de locale (de, de-at, de-ch, de-de), causing
        duplicate choices and form processing errors.
        """
        banner = FacebookBannerFactory.create()
        FacebookBannerLocaleFactory.create(banner=banner, locale='de')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-at')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-ch')
        FacebookBannerLocaleFactory.create(banner=banner, locale='de-de')

        form = self.form('de')
        eq_(len(form.fields['banner'].choices), 1)
Esempio n. 17
0
 def test_fb_banner_thumbnail_rename(self):
     banner = FacebookBannerFactory.create(name='Test banner')
     filename = fb_banner_thumbnail_rename(banner, 'test.png')
     eq_(filename, 'simple/path/thumb_test-banner.png')
Esempio n. 18
0
 def test_fb_banner_thumbnail_rename(self):
     banner = FacebookBannerFactory.create(name='Test banner')
     filename = fb_banner_thumbnail_rename(banner, 'test.png')
     eq_(filename, 'simple/path/thumb_test-banner.png')