Appends platform to addon for duplicates in fail emails (bug 658036 c11)

This commit is contained in:
Kumar McMillan 2011-06-13 11:22:43 -05:00
Родитель 6ca2673442
Коммит 14815e9b75
2 изменённых файлов: 30 добавлений и 9 удалений

Просмотреть файл

@ -153,12 +153,15 @@ def add_validation_jobs(pks, job_pk, **kw):
bulk_validate_file.delay(result.pk)
def get_context(addon, version, job, results):
def get_context(addon, version, job, results, fileob=None):
result_links = (absolutify(reverse('devhub.validation_result',
args=[addon.slug, r.pk]))
for r in results)
addon_name = addon.name
if fileob and fileob.platform.id != amo.PLATFORM_ALL.id:
addon_name = u'%s (%s)' % (addon_name, fileob.platform)
return Context({
'ADDON_NAME': addon.name,
'ADDON_NAME': addon_name,
'ADDON_VERSION': version.version,
'APPLICATION': str(job.application),
'COMPAT_LINK': absolutify(reverse('devhub.versions.edit',
@ -189,8 +192,8 @@ def notify_success(version_pks, job_pk, data, **kw):
app_flag = False
dry_run = data['preview_only']
for app in version.apps.filter(application=
job.curr_max_version.application):
for app in version.apps.filter(
application=job.curr_max_version.application):
if (app.max.version == job.curr_max_version.version and
job.target_version.version != app.max.version):
log.info('Updating version %s%s for addon %s from version %s '
@ -246,7 +249,7 @@ def notify_failed(file_pks, job_pk, data, **kw):
file = result.file
version = file.version
addon = version.addon
context = get_context(addon, version, job, [result])
context = get_context(addon, version, job, [result], fileob=file)
for author in addon.authors.all():
log.info(u'Emailing %s%s for addon %s, file %s about '
'error from bulk validation job %s'

Просмотреть файл

@ -88,8 +88,8 @@ class TestFlagged(test_utils.TestCase):
class BulkValidationTest(test_utils.TestCase):
fixtures = ['base/apps', 'base/addon_3615', 'base/appversion',
'base/users']
fixtures = ['base/apps', 'base/platforms', 'base/addon_3615',
'base/appversion', 'base/users']
def setUp(self):
assert self.client.login(username='admin@mozilla.com',
@ -122,12 +122,12 @@ class BulkValidationTest(test_utils.TestCase):
kw.update(kwargs)
return ValidationJob.objects.create(**kw)
def create_file(self, version=None):
def create_file(self, version=None, platform_id=amo.PLATFORM_ALL.id):
if not version:
version = self.version
return File.objects.create(version=version,
filename='file-%s' % self.counter,
platform_id=amo.PLATFORM_ALL.id,
platform_id=platform_id,
status=amo.STATUS_PUBLIC)
def create_result(self, job, f, **kwargs):
@ -571,6 +571,24 @@ class TestBulkNotify(BulkValidationTest):
f = NotifyForm({'text': '{{ UNDECLARED }}', 'subject': '...'})
eq_(f.is_valid(), False)
def test_addon_name_contains_platform(self):
for pl in (amo.PLATFORM_MAC.id, amo.PLATFORM_LINUX.id):
f = self.create_file(self.version, platform_id=pl)
self.create_result(self.job, f, errors=1)
self.client.post(self.update_url, {'text': '...',
'subject': '{{ ADDON_NAME }}'})
subjects = sorted(m.subject for m in mail.outbox)
eq_(subjects,
['Delicious Bookmarks (Linux)',
'Delicious Bookmarks (Mac OS X)'])
def test_addon_name_for_platform_all(self):
f = self.create_file(self.version, platform_id=amo.PLATFORM_ALL.id)
self.create_result(self.job, f, errors=1)
self.client.post(self.update_url, {'text': '...',
'subject': '{{ ADDON_NAME }}'})
eq_(mail.outbox[0].subject, unicode(self.addon.name))
class TestBulkValidationTask(BulkValidationTest):