-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclean_hunter_test.py
More file actions
62 lines (48 loc) · 1.8 KB
/
clean_hunter_test.py
File metadata and controls
62 lines (48 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
"""
Clean test script for Hunter.io rate limiting.
"""
import sys
import os
import time
import logging
# Add the project root to the Python path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from services.email_finder import EmailFinder
from utils.configuration_service import get_configuration_service
from utils.logging_config import setup_logging
from utils.error_handling import get_error_handler
# Set up logging
setup_logging()
logger = logging.getLogger(__name__)
def test_clean_request():
"""Test a single request with clean error tracking."""
logger.info("Testing clean Hunter.io request...")
# Get configuration
config_service = get_configuration_service()
config = config_service.get_config()
# Initialize email finder
email_finder = EmailFinder(config)
# Test with a simple valid domain that should not have emails
test_domain = "nonexistentdomain12345.com"
logger.info(f"Testing with rate limit of {config.hunter_requests_per_minute} requests per minute")
try:
logger.info(f"Searching domain: {test_domain}")
start_time = time.time()
emails = email_finder.find_company_emails(test_domain)
end_time = time.time()
logger.info(f"Found {len(emails)} emails for {test_domain} in {end_time - start_time:.2f}s")
return True
except Exception as e:
logger.error(f"Error searching domain {test_domain}: {e}")
return False
if __name__ == "__main__":
# Clear error tracking
error_handler = get_error_handler()
error_handler.errors.clear()
error_handler.error_counts.clear()
success = test_clean_request()
if success:
logger.info("Test completed successfully!")
else:
logger.error("Test failed!")