Fix tests broken after refactoring editors.models.
This commit is contained in:
Родитель
1b49e1074c
Коммит
494ad71b25
|
@ -204,7 +204,7 @@ class EditorQueueTable(SQLTable, ItemStateTable):
|
|||
def render_platforms(self, row):
|
||||
icons = []
|
||||
html = u'<div class="platform-icon plat-sprite-%s" title="%s"></div>'
|
||||
for platform in row.file_platforms:
|
||||
for platform in row.file_platform_ids:
|
||||
icons.append(html % (amo.PLATFORMS[int(platform)].shortname,
|
||||
amo.PLATFORMS[int(platform)].name))
|
||||
return u''.join(icons)
|
||||
|
|
|
@ -160,7 +160,7 @@ class ViewQueue(RawSQLModel):
|
|||
return self.premium_type in amo.ADDON_PREMIUMS
|
||||
|
||||
@property
|
||||
def file_platforms(self):
|
||||
def file_platform_ids(self):
|
||||
return self._explode_concat(self._file_platform_ids)
|
||||
|
||||
@property
|
||||
|
|
|
@ -45,7 +45,6 @@ class TestViewPendingQueueTable(amo.tests.TestCase):
|
|||
row.addon_name = 'フォクすけといっしょ'.decode('utf8')
|
||||
row.addon_slug = 'test'
|
||||
row.latest_version = u'0.12'
|
||||
row.latest_version_id = 1234
|
||||
self.table.set_page(page)
|
||||
a = pq(self.table.render_addon_name(row))
|
||||
|
||||
|
@ -113,9 +112,8 @@ class TestAdditionalInfoInQueue(amo.tests.TestCase):
|
|||
qs = Mock()
|
||||
self.table = helpers.ViewPendingQueueTable(qs)
|
||||
self.row = Mock()
|
||||
self.row.latest_version_id = 1
|
||||
self.row.is_site_specific = False
|
||||
self.row.file_platforms = [amo.PLATFORM_ALL.id]
|
||||
self.row.file_platform_ids = [amo.PLATFORM_ALL.id]
|
||||
self.row.external_software = False
|
||||
self.row.binary = False
|
||||
self.row.binary_components = False
|
||||
|
@ -128,7 +126,7 @@ class TestAdditionalInfoInQueue(amo.tests.TestCase):
|
|||
eq_(self.table.render_additional_info(self.row), u'Site Specific')
|
||||
|
||||
def test_platform(self):
|
||||
self.row.file_platforms = [amo.PLATFORM_LINUX.id]
|
||||
self.row.file_platform_ids = [amo.PLATFORM_LINUX.id]
|
||||
assert "plat-sprite-linux" in self.table.render_platforms(self.row)
|
||||
|
||||
def test_combo(self):
|
||||
|
@ -138,12 +136,12 @@ class TestAdditionalInfoInQueue(amo.tests.TestCase):
|
|||
u'Site Specific, Requires External Software')
|
||||
|
||||
def test_all_platforms(self):
|
||||
self.row.file_platforms = [amo.PLATFORM_ALL.id]
|
||||
self.row.file_platform_ids = [amo.PLATFORM_ALL.id]
|
||||
assert "plat-sprite-all" in self.table.render_platforms(self.row)
|
||||
|
||||
def test_mixed_platforms(self):
|
||||
self.row.file_platforms = [amo.PLATFORM_ALL.id,
|
||||
amo.PLATFORM_LINUX.id]
|
||||
self.row.file_platform_ids = [amo.PLATFORM_ALL.id,
|
||||
amo.PLATFORM_LINUX.id]
|
||||
assert "plat-sprite-linux" in self.table.render_platforms(self.row)
|
||||
assert "plat-sprite-all" in self.table.render_platforms(self.row)
|
||||
|
||||
|
|
|
@ -21,25 +21,29 @@ from users.models import UserProfile
|
|||
|
||||
def create_addon_file(name, version_str, addon_status, file_status,
|
||||
platform=amo.PLATFORM_ALL, application=amo.FIREFOX,
|
||||
admin_review=False, addon_type=amo.ADDON_EXTENSION):
|
||||
app, created = Application.objects.get_or_create(id=application.id,
|
||||
guid=application.guid)
|
||||
app_vr, created = AppVersion.objects.get_or_create(application=app,
|
||||
version='1.0')
|
||||
pl, created = Platform.objects.get_or_create(id=platform.id)
|
||||
admin_review=False, addon_type=amo.ADDON_EXTENSION,
|
||||
created=None):
|
||||
app, created_ = Application.objects.get_or_create(id=application.id,
|
||||
guid=application.guid)
|
||||
app_vr, created_ = AppVersion.objects.get_or_create(application=app,
|
||||
version='1.0')
|
||||
pl, created_ = Platform.objects.get_or_create(id=platform.id)
|
||||
try:
|
||||
ad = Addon.objects.get(name__localized_string=name)
|
||||
except Addon.DoesNotExist:
|
||||
ad = Addon.objects.create(type=addon_type, name=name)
|
||||
if admin_review:
|
||||
ad.update(admin_review=True)
|
||||
vr, created = Version.objects.get_or_create(addon=ad, version=version_str)
|
||||
va, created = ApplicationsVersions.objects.get_or_create(
|
||||
vr, created_ = Version.objects.get_or_create(addon=ad, version=version_str)
|
||||
va, created_ = ApplicationsVersions.objects.get_or_create(
|
||||
version=vr, application=app, min=app_vr, max=app_vr)
|
||||
file_ = File.objects.create(version=vr, filename=u"%s.xpi" % name,
|
||||
platform=pl, status=file_status)
|
||||
# Update status *after* there are files:
|
||||
Addon.objects.get(pk=ad.id).update(status=addon_status)
|
||||
if created:
|
||||
vr.update(created=created)
|
||||
file_.update(created=created)
|
||||
return {'addon': ad, 'version': vr, 'file': file_}
|
||||
|
||||
|
||||
|
@ -62,12 +66,11 @@ class TestQueue(amo.tests.TestCase):
|
|||
__test__ = False # this is an abstract test case
|
||||
|
||||
def test_latest_version(self):
|
||||
self.new_file(version=u'0.1')
|
||||
self.new_file(version=u'0.2')
|
||||
self.new_file(version=u'0.1', created=self.days_ago(2))
|
||||
self.new_file(version=u'0.2', created=self.days_ago(1))
|
||||
latest = self.new_file(version=u'0.3')
|
||||
row = self.Queue.objects.get()
|
||||
eq_(row.latest_version, '0.3')
|
||||
eq_(row.latest_version_id, latest['version'].id)
|
||||
|
||||
def test_file_platforms(self):
|
||||
# Here's a dupe platform in another version:
|
||||
|
|
Загрузка…
Ссылка в новой задаче