예제 #1
0
    def test_match(self):
        # Note: This isn't an exhaustive test. Just a rough cursory check.

        # TriggerRule that matches everything matches everything.
        tr = TriggerRuleFactory(versions=[], locales=[], keywords=[], products=[])
        trm = tr.get_matcher()

        resp = ResponseFactory()
        assert trm.match(resp) is True

        tr = TriggerRuleFactory(versions=[u"38*"], locales=[u"en-US", u"fr"], keywords=[u"rc4"], url_exists=True)
        prod = ProductFactory()
        tr.products.add(prod)
        trm = tr.get_matcher()

        resp = ResponseFactory(
            version=u"38.0.5",
            locale=u"en-US",
            product=prod.db_name,
            description=u"rc4 is awesome",
            url=u"https://example.com/",
        )
        assert trm.match(resp) is True
        resp.locale = "es"
        assert trm.match(resp) is False
예제 #2
0
파일: test_models.py 프로젝트: TroJan/fjord
    def test_match(self):
        # Note: This isn't an exhaustive test. Just a rough cursory check.

        # TriggerRule that matches everything matches everything.
        tr = TriggerRuleFactory(
            versions=[],
            locales=[],
            keywords=[],
            products=[],
        )

        resp = ResponseFactory()
        assert tr.match(resp) is True

        tr = TriggerRuleFactory(
            versions=[u'38*'],
            locales=[u'en-US', u'fr'],
            keywords=[u'rc4'],
            url_exists=True
        )
        prod = ProductFactory()
        tr.products.add(prod)
        resp = ResponseFactory(
            version=u'38.0.5',
            locale=u'en-US',
            product=prod.db_name,
            description=u'rc4 is awesome',
            url=u'https://example.com/'
        )
        assert tr.match(resp) is True
        resp.locale = 'es'
        assert tr.match(resp) is False
예제 #3
0
파일: test_models.py 프로젝트: xrile/fjord
    def test_match(self):
        # Note: This isn't an exhaustive test. Just a rough cursory check.

        # TriggerRule that matches everything matches everything.
        tr = TriggerRuleFactory(
            versions=[],
            locales=[],
            keywords=[],
            products=[],
        )
        trm = tr.get_matcher()

        resp = ResponseFactory()
        assert trm.match(resp) is True

        tr = TriggerRuleFactory(
            versions=[u'38*'],
            locales=[u'en-US', u'fr'],
            keywords=[u'rc4'],
            url_exists=True
        )
        prod = ProductFactory()
        tr.products.add(prod)
        trm = tr.get_matcher()

        resp = ResponseFactory(
            version=u'38.0.5',
            locale=u'en-US',
            product=prod.db_name,
            description=u'rc4 is awesome',
            url=u'https://example.com/'
        )
        assert trm.match(resp) is True
        resp.locale = 'es'
        assert trm.match(resp) is False