Test complete data processing pipeline
()
| 161 | return True |
| 162 | |
| 163 | def test_data_processing(): |
| 164 | """Test complete data processing pipeline""" |
| 165 | print("\n🔄 Testing complete data processing pipeline...") |
| 166 | |
| 167 | from processors.data_processor import OceanHazardDataProcessor |
| 168 | |
| 169 | # Create test social media posts |
| 170 | test_posts = [ |
| 171 | { |
| 172 | "id": "test_001", |
| 173 | "platform": "twitter", |
| 174 | "text": "Tsunami warning issued for coastal areas! Evacuate immediately! #tsunami #emergency", |
| 175 | "user": "test_user", |
| 176 | "timestamp": datetime.now().isoformat(), |
| 177 | "likes": 150, |
| 178 | "retweets": 45, |
| 179 | "replies": 12, |
| 180 | "followers": 1000 |
| 181 | }, |
| 182 | { |
| 183 | "id": "test_002", |
| 184 | "platform": "facebook", |
| 185 | "text": "Heavy rainfall causing flooding in the city. Stay safe everyone!", |
| 186 | "user": "weather_authority", |
| 187 | "timestamp": datetime.now().isoformat(), |
| 188 | "likes": 89, |
| 189 | "shares": 23, |
| 190 | "comments": 8, |
| 191 | "followers": 5000 |
| 192 | }, |
| 193 | { |
| 194 | "id": "test_003", |
| 195 | "platform": "instagram", |
| 196 | "text": "Beautiful sunset at the beach today 🌅", |
| 197 | "user": "beach_lover", |
| 198 | "timestamp": datetime.now().isoformat(), |
| 199 | "likes": 234, |
| 200 | "comments": 15, |
| 201 | "followers": 500 |
| 202 | } |
| 203 | ] |
| 204 | |
| 205 | processor = OceanHazardDataProcessor() |
| 206 | |
| 207 | # Process the posts |
| 208 | processed_posts = processor.process_batch(test_posts) |
| 209 | |
| 210 | print(f" Processed {len(processed_posts)} posts") |
| 211 | |
| 212 | # Display results |
| 213 | for i, post in enumerate(processed_posts): |
| 214 | print(f"\n Post {i+1} ({post['platform']}):") |
| 215 | print(f" Original: {post['original_text'][:50]}...") |
| 216 | print(f" Cleaned: {post['cleaned_text'][:50]}...") |
| 217 | print(f" Hazard: {post['hazard_analysis']['type']} ({post['hazard_analysis']['urgency']})") |
| 218 | print(f" Sentiment: {post['sentiment_analysis']['sentiment_label']}") |
| 219 | print(f" Confidence: {post['hazard_analysis']['confidence']:.2f}") |
| 220 |
no test coverage detected