def test_reportApprovalConflict_sets_error_output_just_once(self): # Repeated occurrence of the same approval conflict will not # result in repeated setting of error_output. series = self.factory.makeProductSeries() domain = self.factory.getUniqueString() templates = [ self.factory.makePOTemplate(productseries=series, translation_domain=domain) for counter in range(3) ] entry = removeSecurityProxy( self.factory.makeTranslationImportQueueEntry()) entry.reportApprovalConflict(domain, len(templates), templates) original_error = entry.error_output transaction.commit() # Try reporting the conflict again, with the templates # reshuffled to see if reportApprovalConflict can be fooled into # thinking it's a different error. Make as sure as we can that # entry.error_output is not modified. slave_entry = ISlaveStore(entry).get(TranslationImportQueueEntry, entry.id) slave_entry.setErrorOutput = FakeMethod() slave_entry.reportApprovalConflict(domain, len(templates), reversed(templates)) self.assertEqual(original_error, slave_entry.error_output) self.assertIn(domain, original_error) self.assertEqual(0, slave_entry.setErrorOutput.call_count)
def test_reportApprovalConflict_sets_error_output_just_once(self): # Repeated occurrence of the same approval conflict will not # result in repeated setting of error_output. series = self.factory.makeProductSeries() domain = self.factory.getUniqueString() templates = [ self.factory.makePOTemplate( productseries=series, translation_domain=domain) for counter in xrange(3)] entry = removeSecurityProxy( self.factory.makeTranslationImportQueueEntry()) entry.reportApprovalConflict(domain, len(templates), templates) original_error = entry.error_output transaction.commit() # Try reporting the conflict again, with the templates # reshuffled to see if reportApprovalConflict can be fooled into # thinking it's a different error. Make as sure as we can that # entry.error_output is not modified. slave_entry = ISlaveStore(entry).get( TranslationImportQueueEntry, entry.id) slave_entry.setErrorOutput = FakeMethod() slave_entry.reportApprovalConflict( domain, len(templates), reversed(templates)) self.assertEqual(original_error, slave_entry.error_output) self.assertIn(domain, original_error) self.assertEqual(0, slave_entry.setErrorOutput.call_count)