@@ -370,6 +370,7 @@ def test_mixed_full_and_shortened_urls(self, mock_expand):
370
370
371
371
# Simulate the expansion of the shortened URLs
372
372
mock_expand .side_effect = [
373
+ "https://www.amazon.com/dp/product123" , # Long URL link, expands as itself
373
374
"https://www.amazon.com/dp/product456" , # Expanded URL for amzn.to
374
375
"https://www.aliexpress.com/item/1005001234567890.html" , # Expanded URL for aliexpress shortened link
375
376
]
@@ -378,6 +379,7 @@ def test_mixed_full_and_shortened_urls(self, mock_expand):
378
379
domains , modified_message = extract_domains_from_message (message_text )
379
380
380
381
# Check that the expand_shortened_url function was called twice with correct URLs
382
+ mock_expand .assert_any_call ("https://www.amazon.com/dp/product123" )
381
383
mock_expand .assert_any_call ("https://amzn.to/abc123" )
382
384
mock_expand .assert_any_call ("https://s.click.aliexpress.com/e/buyproduct" )
383
385
@@ -501,24 +503,24 @@ def test_extract_domains_with_long_urls(self):
501
503
"""
502
504
Test: Extract domains from long Amazon and AliExpress URLs.
503
505
"""
504
- # Texto con URLs largas ya expandidas
506
+ # Text with long URLs already expanded
505
507
message_text = (
506
508
"Check out this Amazon deal: https://www.amazon.com/dp/B08XYZ123 "
507
- "and this AliExpress: https://www .aliexpress.com/item/12345.html"
509
+ "and this AliExpress: https://es .aliexpress.com/item/12345.html" ## We use a localized URL because expanding always, can change generic to local URL
508
510
)
509
511
510
- # Llama a la función que procesa el mensaje
512
+ # Call the function that processes the message
511
513
domains , modified_message = extract_domains_from_message (message_text )
512
514
513
- # Verifica que los dominios correctos fueron extraídos
514
- self .assertIn ("amazon.com" , domains ) # Debería encontrar amazon.com
515
- self .assertIn ("aliexpress.com" , domains ) # Debería encontrar aliexpress.com
515
+ # Verify that the correct domains were extracted
516
+ self .assertIn ("amazon.com" , domains ) # Should find amazon.com
517
+ self .assertIn ("aliexpress.com" , domains ) # Should find aliexpress.com
516
518
517
- # Verifica que las URLs completas estén presentes en el mensaje modificado
519
+ # Verify that the full URLs are present in the modified message
518
520
self .assertIn ("https://www.amazon.com/dp/B08XYZ123" , modified_message )
519
- self .assertIn ("https://www. aliexpress.com/item/12345.html" , modified_message )
521
+ self .assertIn ("aliexpress.com/item/12345.html" , modified_message ) # Should find aliexpress.com (not checking exact subdomain, as it may expand to different regions )
520
522
521
- # Asegúrate de que no hubo modificaciones innecesarias
523
+ # Ensure there were no unnecessary modifications
522
524
self .assertEqual (message_text , modified_message )
523
525
524
526
0 commit comments