本文整理汇总了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)