Skip to content

Commit

Permalink
Adds [additional] additional info to queue (bug 632166)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar303 committed Mar 4, 2011
1 parent 0dcab0f commit 6b31b41
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 30 deletions.
17 changes: 10 additions & 7 deletions apps/editors/helpers.py
Expand Up @@ -54,16 +54,19 @@ def render_addon_type_id(self, row):
return amo.ADDON_TYPE[row.addon_type_id]

def render_additional_info(self, row):
info = []
if row.is_site_specific:
r = _(u'Site Specific')
elif (len(row.file_platform_ids) == 1
and row.file_platform_ids != [amo.PLATFORM_ALL.id]):
info.append(_(u'Site Specific'))
if (len(row.file_platform_ids) == 1
and row.file_platform_ids != [amo.PLATFORM_ALL.id]):
k = row.file_platform_ids[0]
# L10n: first argument is the platform such as Linux, Mac OS X
r = _(u'{0} only').format(amo.PLATFORMS[k].name)
else:
r = ''
return jinja2.escape(r)
info.append(_(u'{0} only').format(amo.PLATFORMS[k].name))
if row.external_software:
info.append(_(u'Requires External Software'))
if row.binary:
info.append(_(u'Binary Components'))
return u', '.join([jinja2.escape(i) for i in info])

def render_applications(self, row):
# TODO(Kumar) show supported version ranges on hover (if still needed)
Expand Down
71 changes: 48 additions & 23 deletions apps/editors/tests/test_helpers.py
Expand Up @@ -58,29 +58,6 @@ def test_addon_type_id(self):
row.addon_type_id = amo.ADDON_THEME
eq_(unicode(self.table.render_addon_type_id(row)), u'Theme')

def test_additional_info_site_specific(self):
row = Mock()
row.is_site_specific = True
eq_(self.table.render_additional_info(row), u'Site Specific')

def test_additional_info_for_platform(self):
row = Mock()
row.is_site_specific = False
row.file_platform_ids = [amo.PLATFORM_LINUX.id]
eq_(self.table.render_additional_info(row), u'Linux only')

def test_additional_info_for_all_platforms(self):
row = Mock()
row.is_site_specific = False
row.file_platform_ids = [amo.PLATFORM_ALL.id]
eq_(self.table.render_additional_info(row), u'')

def test_additional_info_for_mixed_platforms(self):
row = Mock()
row.is_site_specific = False
row.file_platform_ids = [amo.PLATFORM_ALL.id, amo.PLATFORM_LINUX.id]
eq_(self.table.render_additional_info(row), u'')

def test_applications(self):
row = Mock()
row.application_ids = [amo.FIREFOX.id, amo.THUNDERBIRD.id]
Expand Down Expand Up @@ -134,6 +111,54 @@ def test_no_flags(self):
eq_(self.table.render_flags(row), '')


class TestAdditionalInfoInQueue(test_utils.TestCase):

def setUp(self):
super(TestAdditionalInfoInQueue, self).setUp()
qs = Mock()
self.table = ViewPendingQueueTable(qs)
self.row = Mock()
self.row.is_site_specific = False
self.row.file_platform_ids = [amo.PLATFORM_ALL.id]
self.row.external_software = False
self.row.binary = False

def test_no_info(self):
eq_(self.table.render_additional_info(self.row), '')

def test_site_specific(self):
self.row.is_site_specific = True
eq_(self.table.render_additional_info(self.row), u'Site Specific')

def test_platform(self):
self.row.file_platform_ids = [amo.PLATFORM_LINUX.id]
eq_(self.table.render_additional_info(self.row), u'Linux only')

def test_combo(self):
self.row.is_site_specific = True
self.row.file_platform_ids = [amo.PLATFORM_MAC.id]
eq_(self.table.render_additional_info(self.row),
u'Site Specific, Mac OS X only')

def test_all_platforms(self):
self.row.file_platform_ids = [amo.PLATFORM_ALL.id]
eq_(self.table.render_additional_info(self.row), u'')

def test_mixed_platforms(self):
self.row.file_platform_ids = [amo.PLATFORM_ALL.id,
amo.PLATFORM_LINUX.id]
eq_(self.table.render_additional_info(self.row), u'')

def test_external_software(self):
self.row.external_software = True
eq_(self.table.render_additional_info(self.row),
u'Requires External Software')

def test_binary(self):
self.row.binary = True
eq_(self.table.render_additional_info(self.row), u'Binary Components')


yesterday = datetime.today() - timedelta(days=1)


Expand Down

0 comments on commit 6b31b41

Please sign in to comment.