本文整理汇总了Python中mkt.site.utils.version_factory函数的典型用法代码示例。如果您正苦于以下问题:Python version_factory函数的具体用法?Python version_factory怎么用?Python version_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了version_factory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.request = mock.Mock()
self.app = app_factory(publish_type=mkt.PUBLISH_IMMEDIATE,
version_kw={'version': '1.0',
'created': self.days_ago(5)})
version_factory(addon=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PENDING))
self.app.reload()
开发者ID:ujdhesa,项目名称:zamboni,代码行数:8,代码来源:test_forms.py
示例2: test_already_rated_version
def test_already_rated_version(self):
self.app.update(is_packaged=True)
Review.objects.create(addon=self.app, user=self.user, body="yes")
version_factory(addon=self.app, version="3.0")
self.app.update_version()
res, data = self._get_url(self.list_url, app=self.app.app_slug)
data = json.loads(res.content)
assert data["user"]["can_rate"]
assert not data["user"]["has_rated"]
开发者ID:clouserw,项目名称:zamboni,代码行数:9,代码来源:test_views.py
示例3: test_create
def test_create(self):
version_factory(addon=self.addon, version='1.1')
data = {
'app': self.addon.app_slug,
'version': '1.1',
'note_type': '0',
'body': 'flylikebee'
}
self.addon.addonuser_set.create(user=self.user)
res = self.client.post(self.list_url, data=json.dumps(data))
eq_(res.status_code, 201)
assert self.addon.threads.count()
开发者ID:demagu-sr,项目名称:zamboni,代码行数:12,代码来源:test_views.py
示例4: test_get
def test_get(self, client=None):
first_version = self.app.current_version
rev = Review.objects.create(
addon=self.app, user=self.user, version=first_version, body=u"I lôve this app", rating=5
)
rev.update(created=self.days_ago(2))
rev2 = Review.objects.create(
addon=self.app, user=self.user2, version=first_version, body=u"I also lôve this app", rating=4
)
# Extra review for another app, should be ignored.
extra_app = app_factory()
Review.objects.create(
addon=extra_app, user=self.user, version=extra_app.current_version, body=u"I häte this extra app", rating=1
)
self.app.total_reviews = 2
ver = version_factory(addon=self.app, version="2.0", file_kw=dict(status=mkt.STATUS_PUBLIC))
self.app.update_version()
reset_queries()
res, data = self._get_url(self.list_url, app=self.app.pk, client=client)
eq_(len(data["objects"]), 2)
self._compare_review_data(client, data["objects"][0], rev2)
self._compare_review_data(client, data["objects"][1], rev)
eq_(data["info"]["average"], self.app.average_rating)
eq_(data["info"]["slug"], self.app.app_slug)
eq_(data["info"]["current_version"], ver.version)
if client != self.anon:
eq_(data["user"]["can_rate"], True)
eq_(data["user"]["has_rated"], True)
return res
开发者ID:clouserw,项目名称:zamboni,代码行数:31,代码来源:test_views.py
示例5: test_packaged_app
def test_packaged_app(self):
self.public_app.update(is_packaged=True)
version = version_factory(
addon=self.public_app, file_kw={'status': mkt.STATUS_PENDING})
self.public_app.reload()
eq_(self.public_app.latest_version, version)
self._test_position(self.public_app)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py
示例6: test_delete_version_app_private
def test_delete_version_app_private(self, update_name_mock,
update_manifest_mock, index_mock):
"""Test deletion of current_version when app is APPROVED."""
self.app.update(status=mkt.STATUS_APPROVED)
ver1 = self.app.latest_version
ver2 = version_factory(
addon=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PUBLIC))
eq_(self.app.latest_version, ver2)
eq_(self.app.current_version, ver2)
update_manifest_mock.reset_mock()
index_mock.reset_mock()
self.client.post(self.delete_url, {'version_id': ver2.pk})
self.app.reload()
eq_(self.app.status, mkt.STATUS_APPROVED)
eq_(self.app.latest_version, ver1)
eq_(self.app.current_version, ver1)
eq_(self.app.versions.count(), 1)
eq_(Version.with_deleted.get(pk=ver2.pk).all_files[0].status,
mkt.STATUS_DISABLED)
eq_(update_name_mock.call_count, 1)
eq_(update_manifest_mock.delay.call_count, 1)
eq_(index_mock.delay.call_count, 1)
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:27,代码来源:test_views_versions.py
示例7: test_app_threads
def test_app_threads(self):
version1 = version_factory(addon=self.addon, version='7.12')
thread1 = CommunicationThread.objects.create(
_addon=self.addon, _version=version1, read_permission_public=True)
version2 = version_factory(addon=self.addon, version='1.16')
thread2 = CommunicationThread.objects.create(
_addon=self.addon, _version=version2, read_permission_public=True)
for thread in (thread1, thread2):
res = self.client.get(reverse('comm-thread-detail',
args=[thread.pk]))
eq_(res.status_code, 200)
eq_(json.loads(res.content)['app_threads'],
[{"id": thread2.id, "version__version": version2.version},
{"id": thread1.id, "version__version": version1.version}])
开发者ID:demagu-sr,项目名称:zamboni,代码行数:16,代码来源:test_views.py
示例8: test_extract_latest_version
def test_extract_latest_version(self):
created_date = self.days_ago(5).replace(microsecond=0)
nomination_date = self.days_ago(3).replace(microsecond=0)
version_factory(
addon=self.app, version='43.0',
has_editor_comment=True,
has_info_request=True,
created=created_date,
nomination=nomination_date,
file_kw=dict(status=mkt.STATUS_REJECTED))
obj, doc = self._get_doc()
eq_(doc['latest_version']['status'], mkt.STATUS_REJECTED)
eq_(doc['latest_version']['has_editor_comment'], True)
eq_(doc['latest_version']['has_info_request'], True)
eq_(doc['latest_version']['created_date'], created_date)
eq_(doc['latest_version']['nomination_date'], nomination_date)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:17,代码来源:test_indexers.py
示例9: test_new_rating_for_new_version
def test_new_rating_for_new_version(self):
self.app.update(is_packaged=True)
self._create()
version = version_factory(addon=self.app, version="3.0")
self.app.update_version()
eq_(self.app.reload().current_version, version)
res, data = self._create()
eq_(201, res.status_code)
eq_(data["version"]["version"], "3.0")
开发者ID:clouserw,项目名称:zamboni,代码行数:9,代码来源:test_views.py
示例10: test_new_rating_for_new_version
def test_new_rating_for_new_version(self):
self.app.update(is_packaged=True)
self._create()
version = version_factory(webapp=self.app, version='3.0')
self.app.update_version()
eq_(self.app.reload().current_version, version)
res, data = self._create()
eq_(201, res.status_code)
eq_(data['version']['version'], '3.0')
开发者ID:shahbaz17,项目名称:zamboni,代码行数:9,代码来源:test_views.py
示例11: test_extract_latest_version
def test_extract_latest_version(self):
created_date = self.days_ago(5).replace(microsecond=0)
nomination_date = self.days_ago(3).replace(microsecond=0)
version_factory(
addon=self.app,
version="43.0",
has_editor_comment=True,
has_info_request=True,
created=created_date,
nomination=nomination_date,
file_kw=dict(status=mkt.STATUS_REJECTED),
)
obj, doc = self._get_doc()
eq_(doc["latest_version"]["status"], mkt.STATUS_REJECTED)
eq_(doc["latest_version"]["has_editor_comment"], True)
eq_(doc["latest_version"]["has_info_request"], True)
eq_(doc["latest_version"]["created_date"], created_date)
eq_(doc["latest_version"]["nomination_date"], nomination_date)
开发者ID:Hitechverma,项目名称:zamboni,代码行数:19,代码来源:test_indexers.py
示例12: test_get_anonymous_queries
def test_get_anonymous_queries(self):
first_version = self.app.current_version
Review.objects.create(webapp=self.app, user=self.user,
version=first_version,
body=u'I lôve this app',
rating=5)
Review.objects.create(webapp=self.app, user=self.user2,
version=first_version,
body=u'I also lôve this app',
rating=4)
self.app.total_reviews = 2
version_factory(webapp=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PUBLIC))
self.app.update_version()
reset_queries()
with self.assertNumQueries(7):
# 7 queries:
# - 1 SAVEPOINT
# - 2 for the Reviews queryset and the translations
# - 2 for the Version associated to the reviews (qs + translations)
# - 1 for the File attached to the Version
# - 1 RELEASE SAVEPOINT
#
# Notes:
# - In prod, we actually do COMMIT/ROLLBACK and not
# SAVEPOINT/RELEASE SAVEPOINT. It would be nice to avoid those for
# all GET requests in the API, but it's not trivial to do for
# ViewSets which implement multiple actions through the same view
# function (non_atomic_requests() really want to be applied to the
# view function).
#
# - The query count is slightly higher in prod. In tests, we patch
# get_app() to avoid the app queries to pollute the queries count.
#
# Once we are on django 1.7, we'll be able to play with Prefetch
# to reduce the number of queries further by customizing the
# queryset used for the complex related objects like versions and
# webapp.
with patch('mkt.ratings.views.RatingViewSet.get_app') as get_app:
get_app.return_value = self.app
res, data = self._get_url(self.list_url, client=self.anon,
app=self.app.pk)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:43,代码来源:test_views.py
示例13: generate_packaged_app
def generate_packaged_app(namedict, apptype, categories, developer_name,
privacy_policy=None, device_types=(),
permissions=(), versions=(),
default_locale='en-US', package_file=None,
status=4, uses_flash=False, **kw):
now = datetime.datetime.now()
app = app_factory(categories=categories, name=namedict[default_locale],
complete=False, rated=True, is_packaged=True,
privacy_policy=privacy_policy,
version_kw={
'version': '1.0',
'reviewed': now if status >= 4 else None,
'_developer_name': developer_name},
file_kw={'status': status, 'uses_flash': uses_flash})
if device_types:
for dt in device_types:
app.addondevicetype_set.create(device_type=DEVICE_CHOICES_IDS[dt])
else:
app.addondevicetype_set.create(device_type=1)
f = app.latest_version.all_files[0]
f.update(filename=f.generate_filename())
fp = os.path.join(app.latest_version.path_prefix, f.filename)
try:
os.makedirs(os.path.dirname(fp))
except OSError:
pass
if package_file:
return app
with storage.open(fp, 'w') as out:
generate_app_package(app, out, apptype,
permissions, namedict,
version=app.latest_version)
for i, vspec in enumerate(versions, 1):
st = STATUS_CHOICES_API_LOOKUP[vspec.get("status", "public")]
rtime = (now + datetime.timedelta(i))
v = version_factory(version="1." + str(i), addon=app,
reviewed=rtime if st >= 4 else None,
nomination=rtime if st > 0 else None,
created=rtime,
file_kw={'status': st},
_developer_name=developer_name)
f = v.files.all()[0]
f.update(filename=f.generate_filename())
fp = os.path.join(app.latest_version.path_prefix, f.filename)
try:
os.makedirs(os.path.dirname(fp))
except OSError:
pass
with open(fp, 'w') as out:
generate_app_package(app, out, vspec.get("type", apptype),
vspec.get("permissions", permissions),
namedict, version=v)
app.update_version()
return app
开发者ID:Jobava,项目名称:zamboni,代码行数:54,代码来源:fakedata.py
示例14: test_version_list_packaged
def test_version_list_packaged(self):
self.app.update(is_packaged=True)
version_factory(addon=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PENDING))
self.app = self.get_app()
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list tbody tr').length, 2)
# 1 pending and 1 public.
eq_(doc('#version-list span.status-pending').length, 1)
eq_(doc('#version-list span.status-public').length, 1)
# Check version strings and order of versions.
eq_(map(lambda x: x.text, doc('#version-list h4 a')),
['2.0', '1.0'])
# There should be 2 delete buttons.
eq_(doc('#version-list a.delete-version.button').length, 2)
# Check download url.
eq_(doc('#version-list a.download').eq(0).attr('href'),
self.app.versions.all()[0].all_files[0].get_url_path(''))
eq_(doc('#version-list a.download').eq(1).attr('href'),
self.app.versions.all()[1].all_files[0].get_url_path(''))
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:21,代码来源:test_views_versions.py
示例15: generate_packaged_app
def generate_packaged_app(namedict, apptype, categories, developer_name,
privacy_policy=None, device_types=(),
permissions=(), versions=(),
default_locale='en-US', package_file=None,
status=4, **kw):
now = datetime.datetime.now()
app = app_factory(categories=categories, name=namedict[default_locale],
complete=False, rated=True, is_packaged=True,
privacy_policy=privacy_policy,
version_kw={
'version': '1.0',
'reviewed': now if status >= 4 else None,
'_developer_name': developer_name},
file_kw={'status': status})
if device_types:
for dt in device_types:
app.addondevicetype_set.create(device_type=DEVICE_CHOICES_IDS[dt])
else:
app.addondevicetype_set.create(device_type=1)
f = app.latest_version.all_files[0]
f.update(filename=f.generate_filename())
fp = os.path.join(app.latest_version.path_prefix, f.filename)
if package_file:
package_file_file = open(package_file)
manifest = WebAppParser().get_json_data(package_file_file)
AppManifest.objects.create(
version=app.latest_version, manifest=json.dumps(manifest))
# copy package_file to storage like a normal app.
private_storage.save(fp, package_file_file)
app.update_version()
return app
with private_storage.open(fp, 'w') as out:
generate_app_package(app, out, apptype,
permissions, namedict,
version=app.latest_version)
for i, vspec in enumerate(versions, 1):
st = STATUS_CHOICES_API_LOOKUP[vspec.get("status", "public")]
rtime = (now + datetime.timedelta(i))
v = version_factory(version="1." + str(i), addon=app,
reviewed=rtime if st >= 4 else None,
nomination=rtime if st > 0 else None,
created=rtime,
file_kw={'status': st},
_developer_name=developer_name)
f = v.files.all()[0]
f.update(filename=f.generate_filename())
fp = os.path.join(app.latest_version.path_prefix, f.filename)
with private_storage.open(fp, 'w') as out:
generate_app_package(app, out, vspec.get("type", apptype),
vspec.get("permissions", permissions),
namedict, version=v)
app.update_version()
return app
开发者ID:carriercomm,项目名称:zamboni,代码行数:53,代码来源:fakedata.py
示例16: test_version_number
def test_version_number(self):
version = version_factory(addon=self.addon, version='7.12')
thread = CommunicationThread.objects.create(
_addon=self.addon, _version=version, read_permission_public=True)
res = self.client.get(reverse('comm-thread-detail', args=[thread.pk]))
eq_(json.loads(res.content)['version_number'], '7.12')
eq_(json.loads(res.content)['version_is_obsolete'], False)
version.delete()
res = self.client.get(reverse('comm-thread-detail', args=[thread.pk]))
eq_(json.loads(res.content)['version_number'], '7.12')
eq_(json.loads(res.content)['version_is_obsolete'], True)
开发者ID:demagu-sr,项目名称:zamboni,代码行数:13,代码来源:test_views.py
示例17: test_response_deleted_version_app
def test_response_deleted_version_app(self):
self.addon.update(status=mkt.STATUS_DELETED)
thread = self._thread_factory(note=True)
version = version_factory(addon=self.addon)
version.update(deleted=True)
thread.update(_version=version)
res = self.client.get(
reverse('comm-thread-detail', kwargs={'pk': thread.pk}))
eq_(res.status_code, 200)
eq_(res.json['addon'], self.addon.id)
eq_(res.json['addon_meta']['name'], self.addon.name)
eq_(res.json['version'], version.id)
eq_(res.json['version_number'], version.version)
eq_(res.json['version_is_obsolete'], True)
开发者ID:demagu-sr,项目名称:zamboni,代码行数:16,代码来源:test_views.py
示例18: test_delete_version_app_public
def test_delete_version_app_public(self):
"""Test deletion of current_version when app is PUBLIC."""
eq_(self.app.status, mkt.STATUS_PUBLIC)
ver1 = self.app.latest_version
ver2 = version_factory(
addon=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PUBLIC))
eq_(self.app.latest_version, ver2)
eq_(self.app.current_version, ver2)
self.client.post(self.delete_url, {'version_id': ver2.pk})
self.app.reload()
eq_(self.app.status, mkt.STATUS_PUBLIC)
eq_(self.app.latest_version, ver1)
eq_(self.app.current_version, ver1)
eq_(self.app.versions.count(), 1)
eq_(Version.with_deleted.get(pk=ver2.pk).all_files[0].status,
mkt.STATUS_DISABLED)
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:19,代码来源:test_views_versions.py
示例19: test_version_is_public
def test_version_is_public(self):
addon = Webapp.objects.get(id=337141)
version = version_factory(addon=addon)
# Base test. Everything is in order, the version should be public.
eq_(version.is_public(), True)
# Non-public file.
self._reset_version(version)
version.all_files[0].status = mkt.STATUS_DISABLED
eq_(version.is_public(), False)
# Deleted version.
self._reset_version(version)
version.deleted = True
eq_(version.is_public(), False)
# Non-public addon.
self._reset_version(version)
with mock.patch("mkt.webapps.models.Webapp.is_public") as is_addon_public:
is_addon_public.return_value = False
eq_(version.is_public(), False)
开发者ID:ujdhesa,项目名称:zamboni,代码行数:22,代码来源:test_models.py
示例20: test_delete_last_public_version
def test_delete_last_public_version(self):
"""
Test that deleting the last PUBLIC version but there is an APPROVED
version marks the app as APPROVED.
Similar to the above test but ensures APPROVED versions don't get
confused with PUBLIC versions.
"""
eq_(self.app.versions.count(), 1)
ver1 = self.app.latest_version
ver1.all_files[0].update(status=mkt.STATUS_APPROVED)
ver2 = version_factory(
addon=self.app, version='2.0',
file_kw=dict(status=mkt.STATUS_PUBLIC))
self.client.post(self.delete_url, {'version_id': ver2.pk})
self.app.reload()
eq_(self.app.status, mkt.STATUS_APPROVED)
eq_(self.app.latest_version, ver1)
eq_(self.app.current_version, None)
eq_(self.app.versions.count(), 1)
eq_(Version.with_deleted.get(pk=ver2.pk).all_files[0].status,
mkt.STATUS_DISABLED)
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:23,代码来源:test_views_versions.py
注:本文中的mkt.site.utils.version_factory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论