def test_entered_into_matching_is_blank_before_entering_into_matching(
         self):
     report = Report(owner=self.user)
     report.encrypt_record("test non-matching report", "key")
     report.save()
     self.assertIsNone(
         Report.objects.get(pk=report.id).entered_into_matching)
 def test_deleted_report_doesnt_delete_sent_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
     user2 = User.objects.create_user(username="******", password="******")
     report2 = Report(owner=user2)
     report2.encrypt_record("test report 2", "key")
     report2.save()
     match_report2 = MatchReport(report=report2)
     match_report2.encrypt_match_report("test match report 2", 'dummy')
     match_report2.save()
     sent_match_report = SentMatchReport.objects.create()
     sent_match_report.reports.add(match_report, match_report2)
     self.report.match_found = True
     self.report.save()
     report2.match_found = True
     report2.save()
     self.assertIsNotNone(match_report.sentmatchreport_set.first())
     self.assertIsNotNone(match_report2.sentmatchreport_set.first())
     self.assertEqual(match_report,
                      SentMatchReport.objects.first().reports.all()[0])
     self.assertEqual(match_report2,
                      SentMatchReport.objects.first().reports.all()[1])
     self.report.delete()
     self.assertEqual(Report.objects.count(), 1)
     self.assertEqual(MatchReport.objects.count(), 1)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
     self.assertEqual(SentMatchReport.objects.first().reports.count(), 1)
     self.assertEqual(SentMatchReport.objects.first().reports.first(),
                      match_report2)
     self.assertTrue(Report.objects.first().match_found)
     report2.delete()
     self.assertEqual(Report.objects.count(), 0)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
 def test_entered_into_matching_is_blank_before_entering_into_matching(
         self):
     report = Report(owner=self.user)
     report.encrypt_record("test non-matching report", "key")
     report.save()
     self.assertIsNone(
         Report.objects.get(
             pk=report.id).entered_into_matching)
 def test_can_decrypt_report(self):
     report = Report(owner=self.user)
     report.encrypt_record(
         "this text should be encrypted, yes it should by golly!",
         "this is my key")
     report.save()
     saved_report = Report.objects.first()
     self.assertEqual(
         saved_report.decrypt_record("this is my key"),
         "this text should be encrypted, yes it should by golly!",
     )
 def test_can_decrypt_report(self):
     report = Report(owner=self.user)
     report.encrypt_record(
         "this text should be encrypted, yes it should by golly!",
         'this is my key',
     )
     report.save()
     saved_report = Report.objects.first()
     self.assertEqual(
         saved_report.decrypt_record('this is my key'),
         "this text should be encrypted, yes it should by golly!",
     )
 def test_can_decrypt_old_reports(self):
     legacy_report = LegacyReportData()
     legacy_report.encrypt_record(
         "this text should be encrypted otherwise bad things",
         key="this is my key")
     report = Report(owner=self.user,
                     encrypted=legacy_report.encrypted,
                     salt=legacy_report.salt)
     report.save()
     saved_report = Report.objects.first()
     self.assertEqual(
         saved_report.decrypt_record("this is my key"),
         "this text should be encrypted otherwise bad things",
     )
 def test_can_decrypt_old_reports(self):
     legacy_report = LegacyReportData()
     legacy_report.encrypt_record(
         "this text should be encrypted otherwise bad things",
         key='this is my key',
     )
     report = Report(
         owner=self.user,
         encrypted=legacy_report.encrypted,
         salt=legacy_report.salt,
     )
     report.save()
     saved_report = Report.objects.first()
     self.assertEqual(
         saved_report.decrypt_record('this is my key'),
         "this text should be encrypted otherwise bad things",
     )
    def test_can_decrypt_old_match_report(self):
        legacy_match_report = LegacyMatchReportData()
        legacy_match_report.encrypt_match_report("test legacy match report",
                                                 "dumbo")

        legacy_report = LegacyReportData()
        legacy_report.encrypt_record(
            "this text should be encrypted otherwise bad things",
            key='this is my key')
        report = Report(owner=self.user,
                        encrypted=legacy_report.encrypted,
                        salt=legacy_report.salt)
        report.save()

        new_match_report = MatchReport(
            report=report,
            encrypted=legacy_match_report.encrypted,
            salt=legacy_match_report.salt,
        )
        new_match_report.save()
        self.assertEqual(new_match_report.get_match("dumbo"),
                         "test legacy match report")
 def test_deleted_report_doesnt_delete_sent_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
     user2 = User.objects.create_user(username="******", password="******")
     report2 = Report(owner=user2)
     report2.encrypt_record("test report 2", "key")
     report2.save()
     match_report2 = MatchReport(report=report2)
     match_report2.encrypt_match_report("test match report 2", 'dummy')
     match_report2.save()
     sent_match_report = SentMatchReport.objects.create()
     sent_match_report.reports.add(match_report, match_report2)
     self.report.match_found = True
     self.report.save()
     report2.match_found = True
     report2.save()
     self.assertIsNotNone(match_report.sentmatchreport_set.first())
     self.assertIsNotNone(match_report2.sentmatchreport_set.first())
     self.assertEqual(
         match_report,
         SentMatchReport.objects.first().reports.all()[0])
     self.assertEqual(
         match_report2,
         SentMatchReport.objects.first().reports.all()[1])
     self.report.delete()
     self.assertEqual(Report.objects.count(), 1)
     self.assertEqual(MatchReport.objects.count(), 1)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
     self.assertEqual(SentMatchReport.objects.first().reports.count(), 1)
     self.assertEqual(
         SentMatchReport.objects.first().reports.first(),
         match_report2)
     self.assertTrue(Report.objects.first().match_found)
     report2.delete()
     self.assertEqual(Report.objects.count(), 0)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
    def test_can_decrypt_old_match_report(self):
        legacy_match_report = LegacyMatchReportData()
        legacy_match_report.encrypt_match_report(
            "test legacy match report", "dumbo")

        legacy_report = LegacyReportData()
        legacy_report.encrypt_record(
            "this text should be encrypted otherwise bad things",
            key='this is my key')
        report = Report(
            owner=self.user,
            encrypted=legacy_report.encrypted,
            salt=legacy_report.salt)
        report.save()

        new_match_report = MatchReport(
            report=report,
            encrypted=legacy_match_report.encrypted,
            salt=legacy_match_report.salt,
        )
        new_match_report.save()
        self.assertEqual(
            new_match_report.get_match("dumbo"),
            "test legacy match report")
Beispiel #11
0
 def test_can_withdraw_from_matching(self):
     report = Report(owner=self.user)
     report.encrypt_record("test report", "key")
     report.save()
     MatchReport.objects.create(report=report)
     self.assertIsNotNone(Report.objects.first().entered_into_matching)
     report.match_found = True
     report.save()
     report.withdraw_from_matching()
     report.save()
     self.assertIsNone(Report.objects.first().entered_into_matching)
     self.assertFalse(Report.objects.first().match_found)
 def test_can_withdraw_from_matching(self):
     report = Report(owner=self.user)
     report.encrypt_record("test report", "key")
     report.save()
     MatchReport.objects.create(report=report)
     self.assertIsNotNone(Report.objects.first().entered_into_matching)
     report.match_found = True
     report.save()
     report.withdraw_from_matching()
     report.save()
     self.assertIsNone(Report.objects.first().entered_into_matching)
     self.assertFalse(Report.objects.first().match_found)
Beispiel #13
0
 def test_no_times_by_default(self):
     report = Report(owner=self.user)
     report.encrypt_record("test report", "key")
     report.save()
     self.assertIsNone(Report.objects.first().submitted_to_school)
     self.assertIsNone(Report.objects.first().entered_into_matching)
Beispiel #14
0
 def test_reports_have_owners(self):
     report = Report()
     report.owner = self.user
     report.save()
     self.assertIn(report, self.user.report_set.all())
 def test_no_times_by_default(self):
     report = Report(owner=self.user)
     report.encrypt_record("test report", "key")
     report.save()
     self.assertIsNone(Report.objects.first().submitted_to_school)
     self.assertIsNone(Report.objects.first().entered_into_matching)
 def test_reports_have_owners(self):
     report = Report()
     report.owner = self.user
     report.save()
     self.assertIn(report, self.user .report_set.all())