import unittest from app.contact_extractor import extract_contacts class ContactExtractorTests(unittest.TestCase): def test_extracts_public_mailto_obfuscated_phone_and_ignores_false_positives(self): html = '''
Email Sales info [at] acme.test+27 (12) 345-6789 WhatsAppAPI key: foo@acme.test password: bar@acme.test
', 'https://acme.test/') self.assertEqual(result, []) def test_classifies_role_named_free_mail_and_suppression(self): html = 'support@acme.test alice@acme.test bob@gmail.com
' result = extract_contacts(html, 'https://acme.test/', suppressions=[{'kind':'email','value':'support@acme.test'}]) by = {x['value']: x for x in result} self.assertEqual(by['support@acme.test']['classification'], 'role') self.assertTrue(by['support@acme.test']['do_not_contact']) self.assertTrue(by['support@acme.test']['suppressed']) self.assertEqual(by['alice@acme.test']['classification'], 'named') self.assertEqual(by['bob@gmail.com']['classification'], 'free_mail') self.assertEqual(by['alice@acme.test']['mx_status'], 'unknown') if __name__ == '__main__': unittest.main()