コード例 #1
0
 def test_does_notify_on_reported_reports(self):
     with patch.object(CustomNotificationApi, 'log_action') as api_logging:
         self.create_match(self.user1, 'test1')
         match_report = self.create_match(self.user2, 'test1', alert=False)
         match_report.report.submitted_to_school = timezone.now()
         match_report.report.save()
         MatchingApi.find_matches('test1')
         self.assertNotEqual(api_logging.call_count, 2)  # old behavior
         self.assertEqual(api_logging.call_count, 3)  # new behavior
コード例 #2
0
 def test_does_notify_on_reported_reports(self):
     with patch.object(CustomNotificationApi, 'log_action') as api_logging:
         self.create_match(self.user1, 'test1')
         match_report = self.create_match(self.user2, 'test1', alert=False)
         match_report.report.submitted_to_school = timezone.now()
         match_report.report.save()
         MatchingApi.find_matches('test1')
         self.assertNotEqual(api_logging.call_count, 2)  # old behavior
         self.assertEqual(api_logging.call_count, 3)  # new behavior
コード例 #3
0
    def test_matches_after_encryption(self, mock_process):

        user1 = User.objects.create_user(username="******", password="******")
        Report = self.get_model_before('Report')
        report = Report(owner_id=user1.pk)
        report.save()
        MatchReport = self.get_model_before('MatchReport')
        identifier = "test_identifier"
        phone = "555-1212"
        user_name = "Maggie"
        email = "*****@*****.**"
        perp_name = "Perp"
        MatchReport.objects.create(
            report=report,
            identifier=identifier,
            contact_phone=phone,
            contact_name=user_name,
            contact_email=email,
            name=perp_name,
            seen=True)
        self.assertEqual(MatchReport.objects.count(), 1)

        self.run_migration()

        MatchReport = self.get_model_after('MatchReport')
        MatchReport.objects.first()
        user2 = User.objects.create_user(username="******", password="******")
        Report = self.get_model_after('Report')
        report2 = Report(owner_id=user2.pk)
        report2.save()
        report_content = MatchReportContent(
            identifier='test_identifier',
            perp_name='Perperick',
            contact_name='Rita',
            email='*****@*****.**',
            phone='555-555-1212')
        salt = get_random_string()
        encrypted_report = security.pepper(
            _legacy_encrypt_report(
                salt, identifier, json.dumps(
                    report_content.__dict__)))
        match_report = MatchReport.objects.create(
            report=report2,
            identifier=identifier,
            encrypted=encrypted_report,
            salt=salt)
        MatchingApi.find_matches('test_identifier')
        # have to use ANY because objects in migration tests are faked
        mock_process.assert_called_once_with([ANY, ANY], 'test_identifier')
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
 def _get_matches(self, identifier):
     return MatchingApi.find_matches(identifier)
コード例 #7
0
ファイル: view_partials.py プロジェクト: ojshaw/callisto-core
 def _get_matches(self, identifier):
     return MatchingApi.find_matches(identifier)
コード例 #8
0
 def test_abritrary_method_names_can_be_used(self):
     self.assertEqual(
         MatchingApi.send_claws_to_scratch_couch(),
         None,
     )
コード例 #9
0
 def test_overridden_api_call(self, mock_process):
     MatchingApi.find_matches('arg1')
     mock_process.assert_called_once_with('arg1')
コード例 #10
0
 def test_abritrary_method_names_can_be_used(self):
     self.assertEqual(MatchingApi.send_claws_to_scratch_couch(), None)
コード例 #11
0
 def test_overridden_api_call(self, mock_process):
     MatchingApi.find_matches("arg1")
     mock_process.assert_called_once_with("arg1")