コード例 #1
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    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
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_by_sample_rate(self):
        always_match = RecipeFactory(sample_rate=1.0)
        never_match = RecipeFactory(sample_rate=0.0)
        client = ClientFactory()

        assert always_match.matches(client)
        assert not never_match.matches(client)
コード例 #3
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_by_locale_one(self):
        locale1 = LocaleFactory()
        locale2 = LocaleFactory()
        recipe = RecipeFactory(locales=[locale1])
        client1 = ClientFactory(locale=locale1.code)
        client2 = ClientFactory(locale=locale2.code)

        assert recipe.matches(client1)
        assert not recipe.matches(client2)
コード例 #4
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_by_channel_one(self):
        beta = ReleaseChannelFactory(slug='beta')
        recipe = RecipeFactory(release_channels=[beta])

        release_client = ClientFactory(release_channel='release')
        beta_client = ClientFactory(release_channel='beta')

        assert not recipe.matches(release_client)
        assert recipe.matches(beta_client)
コード例 #5
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_by_country_one(self):
        country1 = CountryFactory()
        country2 = CountryFactory()
        recipe = RecipeFactory(countries=[country1])
        client1 = ClientFactory(country=country1.code)
        client2 = ClientFactory(country=country2.code)

        assert recipe.matches(client1)
        assert not recipe.matches(client2)
コード例 #6
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_by_channel_many(self):
        release = ReleaseChannelFactory(slug='release')
        beta = ReleaseChannelFactory(slug='beta')
        recipe = RecipeFactory(release_channels=[release, beta])

        release_client = ClientFactory(release_channel='release')
        beta_client = ClientFactory(release_channel='beta')
        aurora_client = ClientFactory(release_channel='aurora')

        assert recipe.matches(release_client)
        assert recipe.matches(beta_client)
        assert not recipe.matches(aurora_client)
コード例 #7
0
ファイル: test_views.py プロジェクト: MFBrewster/normandy
    def test_classify_no_sample(self, admin_client):
        """The classify view should ignore sampling."""
        locale = LocaleFactory()
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        recipe = RecipeFactory(sample_rate=0)
        response = admin_client.get('/admin/classifier_preview', {
            'locale': locale.code,
            'release_channel': release_channel.slug,
            'country': country.code
        })

        assert response.status_code == 200
        assert not recipe.matches(response.context['client'])
        assert list(response.context['bundle']) == [recipe]
コード例 #8
0
ファイル: test_views.py プロジェクト: MFBrewster/normandy
    def test_classify_no_sample(self, admin_client):
        """The classify view should ignore sampling."""
        locale = LocaleFactory()
        country = CountryFactory()
        release_channel = ReleaseChannelFactory()

        recipe = RecipeFactory(sample_rate=0)
        response = admin_client.get(
            '/admin/classifier_preview', {
                'locale': locale.code,
                'release_channel': release_channel.slug,
                'country': country.code
            })

        assert response.status_code == 200
        assert not recipe.matches(response.context['client'])
        assert list(response.context['bundle']) == [recipe]
コード例 #9
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
 def test_filter_by_country_none(self):
     recipe = RecipeFactory(countries=[])
     client = ClientFactory(country='US')
     assert recipe.matches(client)
コード例 #10
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
 def test_filter_by_locale_none(self):
     recipe = RecipeFactory(locales=[])
     client = ClientFactory(locale='en-US')
     assert recipe.matches(client)
コード例 #11
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
 def test_filter_by_channel_empty(self):
     recipe = RecipeFactory(release_channels=[])
     client = ClientFactory(release_channel='release')
     assert recipe.matches(client)
コード例 #12
0
ファイル: test_models.py プロジェクト: MFBrewster/normandy
    def test_filter_exclude(self):
        recipe = RecipeFactory(enabled=False)
        client = ClientFactory()

        assert not recipe.matches(client)
        assert recipe.matches(client, exclude=[match_enabled])