예제 #1
0
    def test_filter_exclude_many(self):
        locale_match1, locale_match2, locale_not = LocaleFactory.create_batch(3)
        recipe = RecipeFactory(locales=[locale_match1, locale_match2])
        client = ClientFactory(locale=locale_not.code)

        assert not recipe.matches(client)
        assert recipe.matches(client, exclude=[get_locales])
예제 #2
0
    def test_classify_empty_time(self, admin_client):
        """
        If the request_time isn't provided, default to the current time.
        """
        locale, other_locale = LocaleFactory.create_batch(2)
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        matching_recipe = RecipeFactory(
            enabled=True,
            locales=[locale],
            countries=[country],
            release_channels=[release_channel],
            start_time=aware_datetime(2016, 1, 1),
            end_time=aware_datetime(2016, 1, 3),
        )
        RecipeFactory(locales=[other_locale])  # Non-matching

        with patch('normandy.classifier.middleware.timezone') as timezone:
            timezone.now.return_value = aware_datetime(2016, 1, 2)
            response = admin_client.get('/admin/classifier_preview', {
                'locale': locale.code,
                'release_channel': release_channel.slug,
                'country': country.code,
                'request_time_0': '',
                'request_time_1': '',
            })

        assert response.status_code == 200
        assert list(response.context['bundle']) == [matching_recipe]
예제 #3
0
    def test_classify_empty_time(self, admin_client):
        """
        If the request_time isn't provided, default to the current time.
        """
        locale, other_locale = LocaleFactory.create_batch(2)
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        matching_recipe = RecipeFactory(
            enabled=True,
            locales=[locale],
            countries=[country],
            release_channels=[release_channel],
            start_time=aware_datetime(2016, 1, 1),
            end_time=aware_datetime(2016, 1, 3),
        )
        RecipeFactory(locales=[other_locale])  # Non-matching

        with patch('normandy.classifier.middleware.timezone') as timezone:
            timezone.now.return_value = aware_datetime(2016, 1, 2)
            response = admin_client.get(
                '/admin/classifier_preview', {
                    'locale': locale.code,
                    'release_channel': release_channel.slug,
                    'country': country.code,
                    'request_time_0': '',
                    'request_time_1': '',
                })

        assert response.status_code == 200
        assert list(response.context['bundle']) == [matching_recipe]
예제 #4
0
    def test_classify(self, admin_client):
        locale, other_locale = LocaleFactory.create_batch(2)
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        matching_recipe = RecipeFactory(
            enabled=True,
            locales=[locale],
            countries=[country],
            release_channels=[release_channel],
            start_time=aware_datetime(2016, 1, 1),
            end_time=aware_datetime(2016, 1, 3),
        )
        RecipeFactory(locales=[other_locale])  # Non-matching

        response = admin_client.get('/admin/classifier_preview', {
            'locale': locale.code,
            'release_channel': release_channel.slug,
            'country': country.code,
            'request_time_0': '2016-01-02',
            'request_time_1': '00:00:00',
        })

        assert response.status_code == 200
        assert list(response.context['bundle']) == [matching_recipe]
예제 #5
0
    def test_classify(self, admin_client):
        locale, other_locale = LocaleFactory.create_batch(2)
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        matching_recipe = RecipeFactory(
            enabled=True,
            locales=[locale],
            countries=[country],
            release_channels=[release_channel],
            start_time=aware_datetime(2016, 1, 1),
            end_time=aware_datetime(2016, 1, 3),
        )
        RecipeFactory(locales=[other_locale])  # Non-matching

        response = admin_client.get(
            '/admin/classifier_preview', {
                'locale': locale.code,
                'release_channel': release_channel.slug,
                'country': country.code,
                'request_time_0': '2016-01-02',
                'request_time_1': '00:00:00',
            })

        assert response.status_code == 200
        assert list(response.context['bundle']) == [matching_recipe]