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


Python FeatureProfile.to_list方法代码示例

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


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

示例1: TestLoadFeatureProfile

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import to_list [as 别名]
class TestLoadFeatureProfile(mkt.site.tests.TestCase):
    def setUp(self):
        super(TestLoadFeatureProfile, self).setUp()
        self.profile = FeatureProfile(apps=True)
        self.signature = self.profile.to_signature()

    def test_does_nothing_on_desktop(self):
        request = RequestFactory().get('/?dev=desktop&pro=%s' % self.signature)
        load_feature_profile(request)
        eq_(request.feature_profile, None)

    def test_does_nothing_without_dev_param(self):
        request = RequestFactory().get('/?pro=%s' % self.signature)
        load_feature_profile(request)
        eq_(request.feature_profile, None)
        request = RequestFactory().get(
            '/?device=mobilepro=%s' % self.signature)
        load_feature_profile(request)
        eq_(request.feature_profile, None)

    def test_does_nothing_without_profile_signature(self):
        request = RequestFactory().get('/?dev=firefoxos')
        load_feature_profile(request)
        eq_(request.feature_profile, None)

    def test_does_nothing_if_invalid_profile_signature_is_passed(self):
        request = RequestFactory().get('/?dev=firefoxos&pro=whatever')
        load_feature_profile(request)
        eq_(request.feature_profile, None)

    def test_works(self):
        request = RequestFactory().get(
            '/?dev=firefoxos&pro=%s' % self.signature)
        load_feature_profile(request)
        eq_(request.feature_profile.to_list(), self.profile.to_list())

    @mock.patch('mkt.features.utils.FeatureProfile.from_signature')
    def test_caching_on_request_property(self, from_signature_mock):
        fake_feature_profile = object()
        from_signature_mock.return_value = fake_feature_profile
        request = RequestFactory().get(
            '/?dev=firefoxos&pro=%s' % self.signature)
        load_feature_profile(request)
        eq_(request.feature_profile, fake_feature_profile)

        from_signature_mock.return_value = None
        load_feature_profile(request)
        # Should not be None thanks to the property caching.
        eq_(request.feature_profile, fake_feature_profile)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:51,代码来源:test_utils_.py


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