1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+ """Test script for daily outreach functionality."""
4+ import sys
5+ import os
6+ sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), '..' , 'python' ))
7+
8+ from modules .daily_outreach import DailyOutreach
9+ from modules .data_service import BetterBotBaseDataService
10+ from modules .vk_instance import VkInstance
11+
12+ def test_daily_outreach ():
13+ """Test the daily outreach functionality."""
14+ print ("Testing DailyOutreach functionality..." )
15+
16+ # Create mock VK instance and data service
17+ vk_instance = VkInstance ()
18+ data_service = BetterBotBaseDataService ("test_users" )
19+
20+ # Create daily outreach instance
21+ daily_outreach = DailyOutreach (vk_instance , data_service )
22+
23+ print ("β DailyOutreach instance created successfully" )
24+
25+ # Test question selection
26+ candidates = [12345 , 67890 ]
27+ selection = daily_outreach .select_random_user_and_question (candidates )
28+ if selection :
29+ user_id , question = selection
30+ print (f"β Random selection works: User { user_id } , Question: '{ question } '" )
31+ else :
32+ print ("β Random selection failed" )
33+
34+ # Test response processing
35+ test_responses = [
36+ ("My GitHub is github.com/testuser" , 12345 ),
37+ ("I know Python and JavaScript" , 67890 ),
38+ ("Regular message" , 11111 )
39+ ]
40+
41+ for msg , from_id in test_responses :
42+ processed = daily_outreach .process_potential_response (msg , from_id )
43+ print (f"β Message '{ msg } ' processed: { processed } " )
44+
45+ # Test should_run_daily_outreach
46+ should_run_first = daily_outreach .should_run_daily_outreach ()
47+ should_run_second = daily_outreach .should_run_daily_outreach ()
48+
49+ print (f"β Daily check - First run: { should_run_first } , Second run: { should_run_second } " )
50+
51+ print ("β All tests completed successfully!" )
52+
53+ if __name__ == "__main__" :
54+ test_daily_outreach ()
0 commit comments