def test_recheck(self): partner_bad = PartnerFactory() checks.bootstrap_checks(default_is_active=True) checks.run_all_checks() self.assertEqual(1, FlaggedIssue.objects.count()) issue = FlaggedIssue.objects.first() self.assertEqual(PartnersMustHaveShortNameTestCheck.check_id, issue.issue_id) self.assertEqual(partner_bad, issue.content_object) self.assertEqual(ISSUE_STATUS_NEW, issue.issue_status) update_date = issue.date_updated # initial recheck should not do anything except modify timestamps issue = FlaggedIssue.objects.get(pk=issue.pk) issue.recheck() self.assertEqual(ISSUE_STATUS_NEW, issue.issue_status) self.assertNotEqual(update_date, issue.date_updated) update_date = issue.date_updated # recheck after fixing the issue should update the status to resolved partner_bad.short_name = 'Name added' partner_bad.save() issue = FlaggedIssue.objects.get(pk=issue.pk) issue.recheck() self.assertEqual(ISSUE_STATUS_RESOLVED, issue.issue_status) self.assertNotEqual(update_date, issue.date_updated) update_date = issue.date_updated # recheck after re-creating the issue should update the status to reactivated partner_bad.short_name = '' partner_bad.save() issue = FlaggedIssue.objects.get(pk=issue.pk) issue.recheck() self.assertEqual(ISSUE_STATUS_REACTIVATED, issue.issue_status) self.assertNotEqual(update_date, issue.date_updated)
def test_recheck_with_metadata(self): partner_bad = PartnerFactory(name='bar') checks.bootstrap_checks(default_is_active=True) checks.run_all_checks() self.assertEqual(1, FlaggedIssue.objects.count()) issue = FlaggedIssue.objects.first() self.assertEqual(PartnersNameMustBeFooTestCheck.check_id, issue.issue_id) self.assertEqual(partner_bad, issue.content_object) self.assertEqual(ISSUE_STATUS_NEW, issue.issue_status) partner_bad.name = 'foo' partner_bad.save() issue = FlaggedIssue.objects.get(pk=issue.pk) issue.recheck() self.assertEqual(ISSUE_STATUS_RESOLVED, issue.issue_status)