本文整理汇总了Python中mkt.site.utils.app_factory函数的典型用法代码示例。如果您正苦于以下问题:Python app_factory函数的具体用法?Python app_factory怎么用?Python app_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了app_factory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_installed_pagination
def test_installed_pagination(self):
ins1 = Installed.objects.create(user=self.user, addon=app_factory())
ins1.update(created=self.days_ago(1))
ins2 = Installed.objects.create(user=self.user, addon=app_factory())
ins2.update(created=self.days_ago(2))
ins3 = Installed.objects.create(user=self.user, addon=app_factory())
ins3.update(created=self.days_ago(3))
res = self.client.get(self.list_url, {"limit": 2})
eq_(res.status_code, 200)
data = json.loads(res.content)
eq_(len(data["objects"]), 2)
eq_(data["objects"][0]["id"], ins1.addon.id)
eq_(data["objects"][1]["id"], ins2.addon.id)
eq_(data["meta"]["total_count"], 3)
eq_(data["meta"]["limit"], 2)
eq_(data["meta"]["previous"], None)
eq_(data["meta"]["offset"], 0)
next = urlparse(data["meta"]["next"])
eq_(next.path, self.list_url)
eq_(QueryDict(next.query).dict(), {u"limit": u"2", u"offset": u"2"})
res = self.client.get(self.list_url, {"limit": 2, "offset": 2})
eq_(res.status_code, 200)
data = json.loads(res.content)
eq_(len(data["objects"]), 1)
eq_(data["objects"][0]["id"], ins3.addon.id)
eq_(data["meta"]["total_count"], 3)
eq_(data["meta"]["limit"], 2)
prev = urlparse(data["meta"]["previous"])
eq_(next.path, self.list_url)
eq_(QueryDict(prev.query).dict(), {u"limit": u"2", u"offset": u"0"})
eq_(data["meta"]["offset"], 2)
eq_(data["meta"]["next"], None)
示例2: setUp
def setUp(self):
# Add a public, reviewed app for measure. It took 4 days for this app
# to get reviewed.
self.public_app = app_factory(
version_kw={'created': self.days_ago(7),
'nomination': self.days_ago(7),
'reviewed': self.days_ago(3)})
# Took 8 days for another public app to get reviewed.
app_factory(
version_kw={'nomination': self.days_ago(10),
'reviewed': self.days_ago(2)})
# Add to the queue 2 pending apps for good measure.
app_factory(
status=mkt.STATUS_PENDING,
file_kw={'status': mkt.STATUS_PENDING},
version_kw={'nomination': self.days_ago(3)})
app_factory(
status=mkt.STATUS_PENDING,
file_kw={'status': mkt.STATUS_PENDING},
version_kw={'nomination': self.days_ago(1)})
# A deleted app that shouldn't change calculations.
app_factory(
status=mkt.STATUS_DELETED,
file_kw={'status': mkt.STATUS_PENDING},
version_kw={'nomination': self.days_ago(1)})
示例3: test_removed
def test_removed(self):
# At least one public app must exist for dump_apps to run.
app_factory(name='second app', status=mkt.STATUS_PUBLIC)
app_path = os.path.join(self.export_directory, self.app_path)
app = Webapp.objects.get(pk=337141)
app.update(status=mkt.STATUS_PUBLIC)
self.create_export('tarball-name')
assert private_storage.exists(app_path)
app.update(status=mkt.STATUS_PENDING)
self.create_export('tarball-name')
assert not private_storage.exists(app_path)
示例4: test_installed_order
def test_installed_order(self):
# Should be reverse chronological order.
ins1 = Installed.objects.create(user=self.user, addon=app_factory())
ins1.update(created=self.days_ago(1))
ins2 = Installed.objects.create(user=self.user, addon=app_factory())
ins2.update(created=self.days_ago(2))
res = self.client.get(self.list_url)
eq_(res.status_code, 200)
data = json.loads(res.content)
eq_(len(data['objects']), 2)
eq_(data['objects'][0]['id'], ins1.addon.id)
eq_(data['objects'][1]['id'], ins2.addon.id)
示例5: test_all_results
def test_all_results(self):
for x in range(4):
app_factory(name='chr' + str(x))
self.refresh('webapp')
# Test search limit.
data = self.search(q='chr')
eq_(len(data['objects']), 2)
# Test maximum search result.
data = self.search(q='chr', limit='max')
eq_(len(data['objects']), 3)
示例6: test_removed
def test_removed(self):
# At least one public app must exist for dump_apps to run.
app_factory(name="second app", status=mkt.STATUS_PUBLIC)
app_path = os.path.join(settings.DUMPED_APPS_PATH, "apps", "337", "337141.json")
app = Webapp.objects.get(pk=337141)
app.update(status=mkt.STATUS_PUBLIC)
call_command("process_addons", task="dump_apps")
assert os.path.exists(app_path)
app.update(status=mkt.STATUS_PENDING)
call_command("process_addons", task="dump_apps")
assert not os.path.exists(app_path)
示例7: test_relevant_apps
def test_relevant_apps(self, purchase_ids):
profile = UserProfile.objects.create(email='[email protected]')
purchased_app = app_factory()
purchase_ids.return_value = [purchased_app.pk]
developed_app = app_factory()
developed_app.addonuser_set.create(user=profile)
installed_app = app_factory()
installed_app.installed.create(user=profile)
data = self._test_login()
eq_(data['apps']['installed'], [installed_app.pk])
eq_(data['apps']['purchased'], [purchased_app.pk])
eq_(data['apps']['developed'], [developed_app.pk])
示例8: test_relevant_apps
def test_relevant_apps(self, purchase_ids):
profile = UserProfile.objects.create(email="[email protected]", fxa_uid="fake-uid")
purchased_app = app_factory()
purchase_ids.return_value = [purchased_app.pk]
developed_app = app_factory()
developed_app.addonuser_set.create(user=profile)
installed_app = app_factory()
installed_app.installed.create(user=profile)
data = self._test_login()
eq_(data["apps"]["installed"], [installed_app.pk])
eq_(data["apps"]["purchased"], [purchased_app.pk])
eq_(data["apps"]["developed"], [developed_app.pk])
示例9: setUp
def setUp(self):
(app_factory(), app_factory())
# Need queryset to initialize form.
self.apps = Webapp.objects.all()
self.data = {
'app': self.apps[0].id,
'transaction_type': 1,
'transaction_id': 1,
'date_from_day': '1',
'date_from_month': '1',
'date_from_year': '2012',
'date_to_day': '1',
'date_to_month': '1',
'date_to_year': '2013',
}
示例10: test_filter_by_app_pk
def test_filter_by_app_pk(self):
self.app2 = app_factory()
Review.objects.create(addon=self.app2, user=self.user, body="no")
Review.objects.create(addon=self.app, user=self.user, body="yes")
res, data = self._get_filter(app=self.app.pk)
eq_(data["info"]["slug"], self.app.app_slug)
eq_(data["info"]["current_version"], self.app.current_version.version)
示例11: generate_hosted_app
def generate_hosted_app(name, categories, developer_name,
privacy_policy=None, device_types=(), status=4,
rated=True, uses_flash=False, default_locale='en-US',
**spec):
generated_url = 'http://%s.testmanifest.com/fake-data/manifest.webapp' % (
slugify(name),)
a = app_factory(categories=categories, name=name, complete=False,
privacy_policy=spec.get('privacy_policy'),
file_kw={'status': status, 'uses_flash': uses_flash},
default_locale=default_locale, rated=rated,
manifest_url=spec.get('manifest_url', generated_url))
if device_types:
for dt in device_types:
a.webappdevicetype_set.create(device_type=DEVICE_CHOICES_IDS[dt])
else:
a.webappdevicetype_set.create(device_type=1)
a.versions.latest().update(reviewed=datetime.datetime.now(),
_developer_name=developer_name)
if 'manifest_file' in spec:
AppManifest.objects.create(
version=a._latest_version,
manifest=open(spec['manifest_file']).read())
else:
generate_hosted_manifest(a)
return a
示例12: setUp
def setUp(self):
self.app = app_factory()
self.app_url = get_url('app', self.app.pk)
self.version = self.app.current_version
self.file = self.version.all_files[0]
self.request = RequestFactory()
super(TestVersionStatusViewSet, self).setUp()
示例13: test_update_existing_product
def test_update_existing_product(self):
account = self.make_account()
app = app_factory()
generic_product_uri = '/generic/product/1/'
self.generic_patcher.product.get_object_or_404.return_value = {
'resource_pk': 1,
'resource_uri': generic_product_uri,
}
existing_boku_product_uri = '/boku/product/1/'
self.boku_patcher.product.get_object_or_404.return_value = {
'resource_uri': existing_boku_product_uri
}
patch_mock = Mock()
patch_mock.patch.return_value = {
'resource_uri': existing_boku_product_uri,
'seller_product': generic_product_uri,
'seller_boku': account.uri,
}
self.boku_patcher.by_url.return_value = patch_mock
product = self.boku.product_create(account, app)
eq_(product, existing_boku_product_uri)
self.boku_patcher.by_url.assert_called_with(existing_boku_product_uri)
patch_mock.patch.assert_called_with(data={
'seller_boku': account.uri,
'seller_product': generic_product_uri,
})
示例14: test_create_new_product
def test_create_new_product(self):
account = self.make_account()
app = app_factory()
generic_product_uri = '/generic/product/1/'
boku_product_uri = '/boku/product/1/'
self.generic_patcher.product.get_object_or_404.return_value = {
'resource_pk': 1,
'resource_uri': generic_product_uri,
}
self.boku_patcher.product.get_object_or_404.side_effect = (
ObjectDoesNotExist)
self.boku_patcher.product.post.return_value = {
'resource_uri': boku_product_uri,
'seller_product': generic_product_uri,
'seller_boku': account.uri,
}
product = self.boku.product_create(account, app)
eq_(product, boku_product_uri)
self.boku_patcher.product.post.assert_called_with(data={
'seller_boku': account.uri,
'seller_product': generic_product_uri,
})
示例15: test_rereview_flag_adult
def test_rereview_flag_adult(self):
mkt.set_user(user_factory())
app = app_factory()
app.set_content_ratings({
mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_E,
mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_18,
})
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_T)
assert not app.rereviewqueue_set.count()
assert not ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).exists()
# Adult should get flagged to rereview.
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_A)
eq_(app.rereviewqueue_set.count(), 1)
eq_(ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)
# Test things same same if rating stays the same as adult.
app.set_content_ratings({
mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_A,
})
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_A)
eq_(app.rereviewqueue_set.count(), 1)
eq_(ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)