当前位置: 首页>>代码示例>>Python>>正文


Python ResponseFactory.locale方法代码示例

本文整理汇总了Python中fjord.feedback.tests.ResponseFactory.locale方法的典型用法代码示例。如果您正苦于以下问题:Python ResponseFactory.locale方法的具体用法?Python ResponseFactory.locale怎么用?Python ResponseFactory.locale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fjord.feedback.tests.ResponseFactory的用法示例。


在下文中一共展示了ResponseFactory.locale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_match

# 需要导入模块: from fjord.feedback.tests import ResponseFactory [as 别名]
# 或者: from fjord.feedback.tests.ResponseFactory import locale [as 别名]
    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
开发者ID:TroJan,项目名称:fjord,代码行数:34,代码来源:test_models.py

示例2: test_match

# 需要导入模块: from fjord.feedback.tests import ResponseFactory [as 别名]
# 或者: from fjord.feedback.tests.ResponseFactory import locale [as 别名]
    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
开发者ID:Givemore,项目名称:fjord,代码行数:27,代码来源:test_models.py


注:本文中的fjord.feedback.tests.ResponseFactory.locale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。