def test_hit_trans_deadline_notifications(self): """ Check whether notifications are sent to the correct people whenever a translation period is over. """ timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) self.release.develfreeze_date = timestamp self.release.notifications.before_trans_deadline = True self.release.notifications.save() self.release.save() notify_translation_deadline() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 5) self.assertEqual( mails[0].subject, self._gen_assert_msg('[localhost] Release has ' 'hit the translation deadline: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['reviewer@localhost']) self.assertEqual(mails[3].to, ['team_coordinator@localhost']) self.assertEqual(mails[4].to, ['team_member@localhost'])
def test_in_string_freeze_notifications(self): """ Check whether notifications are sent to the correct people whenever the string freeze period starts. """ timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) self.release.stringfreeze_date = timestamp self.release.notifications.before_stringfreeze = True self.release.notifications.save() self.release.save() notify_string_freeze() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 5) self.assertEqual( mails[0].subject, self._gen_assert_msg('[localhost] Release is in string ' 'freeze period: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['reviewer@localhost']) self.assertEqual(mails[3].to, ['team_coordinator@localhost']) self.assertEqual(mails[4].to, ['team_member@localhost'])
def test_string_freeze_breakage_outsourced(self): """Check string breakage for outsourced projects.""" timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) timestamp2 = datetime.datetime.now() + datetime.timedelta(hours=1) self.release.stringfreeze_date = timestamp self.release.develfreeze_date = timestamp2 self.release.save() ## Loading POT (en_US) into the self.resource3 handler = POHandler('%s/tests.pot' % self.pofile_path) handler.set_language(self.language_en) handler.parse_file(is_source=True) # Resource 3 - Outsourced handler.bind_resource(self.resource3) # We are listing to the post_save_translation signal raised in # _post_save2db method. handler.save2db(is_source=True) # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 3) self.assertEqual( mails[0].subject, self._gen_assert_msg('[localhost] Release string ' 'freeze breakage: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['team_coordinator@localhost'])
def test_in_string_freeze_notifications(self): """ Check whether notifications are sent to the correct people whenever the string freeze period starts. """ timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) self.release.stringfreeze_date = timestamp self.release.notifications.before_stringfreeze = True self.release.notifications.save() self.release.save() notify_string_freeze() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 5) self.assertEqual(mails[0].subject, self._gen_assert_msg( '[localhost] Release is in string ' 'freeze period: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['reviewer@localhost']) self.assertEqual(mails[3].to, ['team_coordinator@localhost']) self.assertEqual(mails[4].to, ['team_member@localhost'])
def test_hit_trans_deadline_notifications(self): """ Check whether notifications are sent to the correct people whenever a translation period is over. """ timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) self.release.develfreeze_date = timestamp self.release.notifications.before_trans_deadline = True self.release.notifications.save() self.release.save() notify_translation_deadline() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 5) self.assertEqual(mails[0].subject, self._gen_assert_msg( '[localhost] Release has ' 'hit the translation deadline: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['reviewer@localhost']) self.assertEqual(mails[3].to, ['team_coordinator@localhost']) self.assertEqual(mails[4].to, ['team_member@localhost'])
def test_string_freeze_breakage_outsourced(self): """Check string breakage for outsourced projects.""" timestamp = datetime.datetime.now() - datetime.timedelta(hours=1) timestamp2 = datetime.datetime.now() + datetime.timedelta(hours=1) self.release.stringfreeze_date = timestamp self.release.develfreeze_date = timestamp2 self.release.save() ## Loading POT (en_US) into the self.resource3 handler = POHandler('%s/tests.pot' % self.pofile_path) handler.set_language(self.language_en) handler.parse_file(is_source=True) # Resource 3 - Outsourced handler.bind_resource(self.resource3) # We are listing to the post_save_translation signal raised in # _post_save2db method. handler.save2db(is_source=True) # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 3) self.assertEqual(mails[0].subject, self._gen_assert_msg( '[localhost] Release string ' 'freeze breakage: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost']) self.assertEqual(mails[2].to, ['team_coordinator@localhost'])
def test_before_string_freeze_notifications(self): """ Check whether notifications are sent to the correct people whenever the string freeze period approaches. """ timestamp = datetime.datetime.now() + datetime.timedelta(hours=47) self.release.stringfreeze_date = timestamp self.release.save() notify_string_freeze() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 2) self.assertEqual(mails[0].subject, '[localhost] Release about to ' 'enter the string freeze period: Release1') self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost'])
def test_before_trans_deadline_notifications(self): """ Check whether notifications are sent to the correct people whenever a the translation deadline approaches. """ timestamp = datetime.datetime.now() + datetime.timedelta(hours=47) self.release.develfreeze_date = timestamp self.release.save() notify_translation_deadline() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 2) self.assertEqual(mails[0].subject, '[localhost] Release about ' 'to hit the translation deadline: Release1') self.assertEqual(mails[0].to, ['team_coordinator@localhost']) self.assertEqual(mails[1].to, ['team_member@localhost'])
def test_before_string_freeze_notifications(self): """ Check whether notifications are sent to the correct people whenever the string freeze period approaches. """ timestamp = datetime.datetime.now() + datetime.timedelta(hours=47) self.release.stringfreeze_date = timestamp self.release.save() notify_string_freeze() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 2) self.assertEqual( mails[0].subject, self._gen_assert_msg('[localhost] Release about to ' 'enter the string freeze period: Release1')) self.assertEqual(mails[0].to, ['maintainer3@localhost']) self.assertEqual(mails[1].to, ['maintainer@localhost'])
def test_before_trans_deadline_notifications(self): """ Check whether notifications are sent to the correct people whenever a the translation deadline approaches. """ timestamp = datetime.datetime.now() + datetime.timedelta(hours=47) self.release.develfreeze_date = timestamp self.release.save() notify_translation_deadline() # Sorted mails list mails = key_sort(mail.outbox, 'to') self.assertEqual(len(mails), 3) self.assertEqual( mails[0].subject, self._gen_assert_msg('[localhost] Release about ' 'to hit the translation deadline: Release1')) self.assertEqual(mails[0].to, ['reviewer@localhost']) self.assertEqual(mails[1].to, ['team_coordinator@localhost']) self.assertEqual(mails[2].to, ['team_member@localhost'])
def get_sorted_stats(obj): return key_sort(obj, '-translated_perc')[:NUM_LANGS]
stats = [] for i in obj: try: translated_perc = int((float(i.translated) / i.total) * 100) except Exception, e: translated_perc = 0 stats.append((translated_perc, i.object)) stats.sort() stats.reverse() _stats = [] for stat in stats[:NUM_LANGS]: _stats.append(PLStat(stat[0], stat[1])) return _stats else: return key_sort(obj, '-translated_perc')[:NUM_LANGS] def get_image_url(obj, project=False): """ Returns URL for the static image """ height = 210 trans = [] fuzzy = [] labels_left = [] labels_right = [] stats = get_sorted_stats(obj, project) for stat in stats:
stats = [] for i in obj: try: translated_perc = int((float(i.translated)/i.total)*100) except Exception, e: translated_perc = 0 stats.append((translated_perc, i.object)) stats.sort() stats.reverse() _stats = [] for stat in stats[:NUM_LANGS]: _stats.append(PLStat(stat[0], stat[1])) return _stats else: return key_sort(obj, '-translated_perc')[:NUM_LANGS] def get_image_url(obj, project=False): """ Returns URL for the static image """ height = 210 trans = [] fuzzy = [] labels_left = [] labels_right = [] stats = get_sorted_stats(obj, project) for stat in stats: t = stat.translated_perc