예제 #1
0
    def test_variation_queryset(self):
        """
        The variation field queryset should be limited to variations
        from the text banner passed in the constructor.
        """
        banner = TextBannerFactory.create()

        variation1, variation2 = TextBannerVariationFactory.create_batch(2, banner=banner)
        ok_(CustomizeTextBannerForm(banner, {'variation': variation1.pk}).is_valid())
        ok_(CustomizeTextBannerForm(banner, {'variation': variation2.pk}).is_valid())

        non_matching_variation = TextBannerVariationFactory.create()
        invalid_form = CustomizeTextBannerForm(banner, {'variation': non_matching_variation.pk})
        ok_(not invalid_form.is_valid())
예제 #2
0
    def test_variation_queryset(self):
        """
        The variation field queryset should be limited to variations
        from the text banner passed in the constructor.
        """
        banner = TextBannerFactory.create()

        variation1, variation2 = TextBannerVariationFactory.create_batch(2, banner=banner)
        ok_(CustomizeTextBannerForm(banner, {'variation': variation1.pk}).is_valid())
        ok_(CustomizeTextBannerForm(banner, {'variation': variation2.pk}).is_valid())

        non_matching_variation = TextBannerVariationFactory.create()
        invalid_form = CustomizeTextBannerForm(banner, {'variation': non_matching_variation.pk})
        ok_(not invalid_form.is_valid())
예제 #3
0
    def test_get_context_data_variations(self):
        view = views.CustomizeTextBannerView()
        view.banner = TextBannerFactory.create()

        variation1, variation2 = TextBannerVariationFactory.create_batch(2, banner=view.banner)

        ctx = view.get_context_data(foo='bar', baz=1)
        eq_(ctx['foo'], 'bar')
        eq_(ctx['baz'], 1)

        variations = json.loads(ctx['variations_text_json'])
        eq_(variations, {
            unicode(variation1.pk): variation1.text,
            unicode(variation2.pk): variation2.text,
        })
예제 #4
0
    def test_get_context_data_variations(self):
        view = views.CustomizeTextBannerView()
        view.banner = TextBannerFactory.create()

        variation1, variation2 = TextBannerVariationFactory.create_batch(
            2, banner=view.banner)

        ctx = view.get_context_data(foo='bar', baz=1)
        eq_(ctx['foo'], 'bar')
        eq_(ctx['baz'], 1)

        variations = json.loads(ctx['variations_text_json'])
        eq_(
            variations, {
                unicode(variation1.pk): variation1.text,
                unicode(variation2.pk): variation2.text,
            })