예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 def test_can_encrypt_record(self):
     report = Report(owner=self.user)
     report.encrypt_record("this text should be encrypted",
                           "this is my key")
     self.assertIsNotNone(report.encode_prefix)
     self.assertNotEqual(report.encode_prefix, "")
     self.assertIsNotNone(report.encrypted)
     self.assertTrue(len(report.encrypted) > 0)
 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_encrypt_record(self):
     report = Report(owner=self.user)
     report.encrypt_record(
         "this text should be encrypted",
         'this is my key',
     )
     self.assertIsNotNone(report.encode_prefix)
     self.assertNotEqual(report.encode_prefix, '')
     self.assertIsNotNone(report.encrypted)
     self.assertTrue(len(report.encrypted) > 0)
예제 #6
0
 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!",
     )
예제 #7
0
class MatchSetup(TestCase):

    fixtures = [
        'callisto_core_notification_data',
    ]

    def setUp(self):
        self.site = Site.objects.get(id=1)
        self.site.domain = 'testserver'
        self.site.save()
        self.user1 = User.objects.create_user(
            username="******",
            password="******",
        )
        self.user2 = User.objects.create_user(
            username="******",
            password="******",
        )
        self.user3 = User.objects.create_user(
            username="******",
            password="******",
        )
        self.user4 = User.objects.create_user(
            username="******",
            password="******",
        )

    def assert_matches_found_true(self):
        self.assert_matches_found(self.assertTrue)

    def assert_matches_found_false(self):
        self.assert_matches_found(self.assertFalse)

    def assert_matches_found(self, assertion):
        for match in MatchReport.objects.all():
            assertion(match.match_found)

    def create_match(self, user, identifier):
        self.most_recent_report = Report(owner=user)
        self.most_recent_report.encrypt_record("test report 1", "key")
        match_report = MatchReport(report=self.most_recent_report)
        match_report_content = MatchReportContent(
            identifier=identifier,
            perp_name=identifier,
            email='*****@*****.**',
            phone="123",
        )
        match_report.encrypt_match_report(
            json.dumps(match_report_content.__dict__),
            identifier,
        )

        matches = MatchingApi.find_matches(identifier)
        return matches
예제 #8
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)
 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!",
     )
예제 #11
0
class MatchSetup(TestCase):

    fixtures = [
        'callisto_core_notification_data',
    ]

    def setUp(self):
        self.site = Site.objects.get(id=1)
        self.site.domain = 'testserver'
        self.site.save()
        self.user1 = User.objects.create_user(
            username="******", password="******",
        )
        self.user2 = User.objects.create_user(
            username="******", password="******",
        )
        self.user3 = User.objects.create_user(
            username="******", password="******",
        )
        self.user4 = User.objects.create_user(
            username="******", password="******",
        )

    def assert_matches_found_true(self):
        self.assert_matches_found(self.assertTrue)

    def assert_matches_found_false(self):
        self.assert_matches_found(self.assertFalse)

    def assert_matches_found(self, assertion):
        for match in MatchReport.objects.all():
            assertion(match.match_found)

    def create_match(self, user, identifier):
        self.most_recent_report = Report(owner=user)
        self.most_recent_report.encrypt_record("test report 1", "key")
        match_report = MatchReport(report=self.most_recent_report)
        match_report_content = MatchReportContent(
            identifier=identifier, perp_name=identifier,
            email='*****@*****.**', phone="123",
        )
        match_report.encrypt_match_report(
            json.dumps(match_report_content.__dict__),
            identifier,
        )

        matches = MatchingApi.find_matches(identifier)
        return matches
예제 #12
0
    def create_match(self, user, identifier):
        report = Report(owner=user)
        report.encrypt_record("test report 1", "key")

        match_report = MatchReport(report=report)
        match_report_content = MatchReportContent(
            identifier=identifier,
            perp_name=identifier,
            email='*****@*****.**',
            phone="123",
        )
        match_report.encrypt_match_report(
            json.dumps(match_report_content.__dict__),
            identifier,
        )

        matches = MatchingApi.find_matches(identifier)
        return matches
 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)
예제 #14
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)
 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)