本文整理汇总了Python中mkt.constants.features.FeatureProfile类的典型用法代码示例。如果您正苦于以下问题:Python FeatureProfile类的具体用法?Python FeatureProfile怎么用?Python FeatureProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FeatureProfile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_feature_compatibility_no_current_version
def test_feature_compatibility_no_current_version(self):
self.app._current_version = None
feature_profile = FeatureProfile(apps=True, nfc=True, mobileid=True)
self.request = RequestFactory().get(
'/?dev=firefoxos&pro=%s' % feature_profile.to_signature())
res = self.serialize(self.app)
eq_(res['feature_compatibility'], None)
开发者ID:ujdhesa,项目名称:zamboni,代码行数:7,代码来源:test_serializers.py
示例2: test_from_old_signature
def test_from_old_signature(self):
profile = FeatureProfile.from_signature(self.signature)
self._test_profile_values(profile)
new_signature = profile.to_signature()
ok_(new_signature != self.signature)
profile = FeatureProfile.from_signature(new_signature)
self._test_profile_values(profile)
开发者ID:jobava-mozilla,项目名称:zamboni,代码行数:7,代码来源:test_features.py
示例3: profile_qs
def profile_qs(self, disabled_features=None):
if disabled_features is None:
disabled_features = {}
profile = FeatureProfile().fromkeys(FeatureProfile(), True)
for feature in disabled_features:
profile[feature] = False
return {'pro': profile.to_signature(), 'dev': 'firefoxos'}
开发者ID:Jobava,项目名称:zamboni,代码行数:7,代码来源:test_filters.py
示例4: test_feature_compatibility_false
def test_feature_compatibility_false(self):
self.app.current_version.features.update(has_apps=True, has_nfc=True)
feature_profile = FeatureProfile(apps=False, nfc=True, mobileid=True)
self.request = RequestFactory().get(
'/?dev=firefoxos&pro=%s' % feature_profile.to_signature())
res = self.serialize(self.app)
eq_(res['feature_compatibility'], False)
开发者ID:mrheides,项目名称:zamboni,代码行数:7,代码来源:test_serializers.py
示例5: test_feature_compatibility_always_none
def test_feature_compatibility_always_none(self):
# ES is already filtering by feature profile for us, so it does not
# make much sense to check for feature compatibility in ES serializer.
self.app.current_version.features.update(has_apps=True, has_nfc=True)
self.reindex(Webapp)
feature_profile = FeatureProfile(apps=False, nfc=True, mobileid=True)
self.request = RequestFactory().get(
'/?dev=firefoxos&pro=%s' % feature_profile.to_signature())
self.request.REGION = mkt.regions.USA
self.request.user = self.profile
res = self.serialize()
eq_(res['feature_compatibility'], None)
开发者ID:mrheides,项目名称:zamboni,代码行数:12,代码来源:test_serializers.py
示例6: TestLoadFeatureProfile
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,代码行数:49,代码来源:test_utils_.py
示例7: _test_kwargs
def _test_kwargs(self, prefix):
profile = FeatureProfile.from_int(self.features)
kwargs = profile.to_kwargs(prefix=prefix)
ok_(all([k.startswith(prefix) for k in kwargs.keys()]))
eq_(kwargs.values().count(False), bin(self.features)[2:].count('0'))
eq_(len(kwargs.values()), len(APP_FEATURES) - len(self.truths))
开发者ID:at13,项目名称:zamboni,代码行数:7,代码来源:test_features.py
示例8: get_feature_profile
def get_feature_profile(self, request):
profile = None
if request.GET.get('dev') in ('firefoxos', 'android'):
sig = request.GET.get('pro')
if sig:
profile = FeatureProfile.from_signature(sig)
return profile
开发者ID:chrisdavidmills,项目名称:zamboni,代码行数:7,代码来源:api.py
示例9: test_from_list
def test_from_list(self):
bools = [False] * MOCK_APP_FEATURES_LIMIT
bools[0] = True # apps
bools[4] = True # light events
bools[15] = True # proximity
bools[19] = True # vibrate
profile = FeatureProfile.from_list(bools)
self._test_profile(profile)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_features.py
示例10: get
def get(self, request, *args, **kwargs):
if 'pro' in request.GET:
self.profile = FeatureProfile.from_signature(request.GET['pro'])
else:
self.profile = None
features = OrderedDict(self._feature(i, slug) for i, slug in
enumerate(APP_FEATURES.keys()))
return Response(features, status=status.HTTP_200_OK)
开发者ID:AALEKH,项目名称:zamboni,代码行数:8,代码来源:views.py
示例11: test_all_good_features_with_category
def test_all_good_features_with_category(self):
"""Enable app features so they exactly match our device profile."""
fp = FeatureProfile.from_signature(self.profile)
self.app.current_version.features.update(**dict(("has_%s" % k, v) for k, v in fp.items()))
self.reindex(Webapp, "webapp")
res = self.client.get(self.list_url + (self.qs,))
eq_(res.status_code, 200)
eq_(len(res.json["featured"]), 1)
eq_(int(res.json["featured"][0]["id"]), self.app.pk)
开发者ID:wraithan,项目名称:zamboni,代码行数:10,代码来源:test_api.py
示例12: _test_kwargs
def _test_kwargs(self, prefix, only_true):
profile = FeatureProfile.from_binary(self.binary)
kwargs = profile.to_kwargs(prefix=prefix, only_true=only_true)
ok_(all([k.startswith(prefix) for k in kwargs.keys()]))
eq_(kwargs.values().count(True), self.binary.count('1'))
if only_true:
eq_(kwargs.values().count(False), 0)
else:
eq_(kwargs.values().count(False), self.binary.count('0'))
开发者ID:MikeLing,项目名称:zamboni,代码行数:10,代码来源:test_features.py
示例13: test_all_good_features
def test_all_good_features(self):
# Enable app features so they exactly match our device profile.
fp = FeatureProfile.from_signature(self.profile)
self.webapp.current_version.features.update(**dict(("has_%s" % k, v) for k, v in fp.items()))
self.webapp.save()
self.refresh("webapp")
res = self.client.get(self.url + (self.qs,))
eq_(res.status_code, 200)
obj = json.loads(res.content)["objects"][0]
eq_(obj["slug"], self.webapp.app_slug)
开发者ID:wraithan,项目名称:zamboni,代码行数:11,代码来源:test_api.py
示例14: test_all_good_features
def test_all_good_features(self):
# Enable app features so they exactly match our device profile.
fp = FeatureProfile.from_signature(self.features)
self.webapp.current_version.features.update(
**dict(('has_%s' % k, v) for k, v in fp.items()))
self.webapp.save()
self.refresh('webapp')
res = self.client.get(self.url, data=self.qs)
eq_(res.status_code, 200)
obj = json.loads(res.content)['objects'][0]
eq_(obj['slug'], self.webapp.app_slug)
开发者ID:j-barron,项目名称:zamboni,代码行数:12,代码来源:test_views.py
示例15: get_feature_profile
def get_feature_profile(request):
profile = None
platforms = ('firefoxos', 'android')
if (request.GET.get('dev') in platforms or
request.GET.get('platform') in platforms):
sig = request.GET.get('pro')
if sig:
try:
profile = FeatureProfile.from_signature(sig)
except ValueError:
pass
return profile
开发者ID:unghost,项目名称:zamboni,代码行数:12,代码来源:utils.py
示例16: field_to_native
def field_to_native(self, obj, field_name):
value = get_component(obj, self.source)
# Filter apps based on feature profiles.
if hasattr(self, 'context') and 'request' in self.context:
sig = self.context['request'].GET.get('pro')
if sig:
try:
profile = FeatureProfile.from_signature(sig)
except ValueError:
pass
else:
value = value.filter(**profile.to_kwargs(
prefix='app___current_version__features__has_'))
return [self.to_native(item) for item in value.all()]
开发者ID:rhelmer,项目名称:zamboni,代码行数:16,代码来源:serializers.py
示例17: device_queue_search
def device_queue_search(request):
"""
Returns a queryset that can be used as a base for searching the device
specific queue.
"""
filters = {
'status': amo.STATUS_PENDING,
'disabled_by_user': False,
}
sig = request.GET.get('pro')
if sig:
profile = FeatureProfile.from_signature(sig)
filters.update(dict(
**profile.to_kwargs(prefix='_latest_version__features__has_')
))
return Webapp.version_and_file_transformer(
Webapp.objects.filter(**filters))
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:17,代码来源:utils.py
示例18: load_feature_profile
def load_feature_profile(request):
"""
Adds a `feature_profile` on the request object if one is present and the
dev parameter is either firefoxos or android.
Does nothing if one was already set.
"""
if hasattr(request, 'feature_profile'):
return
profile = None
if request.GET.get('dev') in ('firefoxos', 'android'):
sig = request.GET.get('pro')
if sig:
try:
profile = FeatureProfile.from_signature(sig)
except ValueError:
pass
request.feature_profile = profile
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:18,代码来源:utils.py
示例19: alter_list_data_to_serialize
def alter_list_data_to_serialize(self, request, data):
form_data = self.search_form(request)
region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
if form_data['cat']:
category = Category.objects.get(pk=form_data['cat'])
else:
category = None
# Filter by device feature profile.
profile = None
if request.GET.get('dev') in ('firefoxos', 'android'):
sig = request.GET.get('pro')
if sig:
profile = FeatureProfile.from_signature(sig)
qs = Webapp.featured(cat=category, region=region, profile=profile)
bundles = [self.build_bundle(obj=obj, request=request) for obj in qs]
data['featured'] = [AppResource().full_dehydrate(bundle)
for bundle in bundles]
return data
开发者ID:MikeLing,项目名称:zamboni,代码行数:21,代码来源:api.py
示例20: alter_list_data_to_serialize
def alter_list_data_to_serialize(self, request, data):
form_data = self.search_form(request)
region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
cat_slug = form_data.get('cat')
if cat_slug:
cat_slug = [cat_slug]
# Filter by device feature profile.
profile = None
if request.GET.get('dev') in ('firefoxos', 'android'):
sig = request.GET.get('pro')
if sig:
profile = FeatureProfile.from_signature(sig)
qs = Webapp.featured(cat=cat_slug, region=region, profile=profile)
bundles = [self.build_bundle(obj=obj, request=request) for obj in qs]
data['featured'] = [AppResource().full_dehydrate(bundle)
for bundle in bundles]
# Alter the _view_name so that statsd logs seperately from search.
request._view_name = 'featured'
return data
开发者ID:smillaedler,项目名称:zamboni,代码行数:22,代码来源:api.py
注:本文中的mkt.constants.features.FeatureProfile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论