@ -4,6 +4,8 @@ from unittest.mock import patch, MagicMock
from content_bot . landing_utils import (
normalize_telegram_url ,
normalize_max_bot_url ,
normalize_logo_url ,
build_landing_meta ,
get_landing_bot_urls ,
)
@ -39,6 +41,33 @@ class LandingUrlNormalizationTests(TestCase):
' https://max.ru/d0323350531_bot ' ,
)
def test_normalize_logo_cdn_path ( self ) :
self . assertEqual (
normalize_logo_url ( ' /cdn/image/kn7m7u.png ' ) ,
' https://cdn.telefon-ip.ru/cdn/image/kn7m7u.png ' ,
)
def test_normalize_logo_full_url ( self ) :
self . assertEqual (
normalize_logo_url ( ' https://saper639.ru/storage/app/media/temp/letobar_logo.png ' ) ,
' https://saper639.ru/storage/app/media/temp/letobar_logo.png ' ,
)
def test_build_landing_meta_includes_og_tags ( self ) :
meta = build_landing_meta (
brand = ' Бар Лето ' ,
description = ' Описание заведения ' ,
logo = ' /cdn/image/kn7m7u.png ' ,
client_id = 2262 ,
page_url = ' https://maxbot.telefon-ip.ru/content/landing/2262/ ' ,
)
self . assertEqual ( meta [ ' og_title ' ] , ' Бар Лето ' )
self . assertEqual ( meta [ ' og_description ' ] , ' Описание заведения ' )
self . assertEqual ( meta [ ' og_image ' ] , ' https://cdn.telefon-ip.ru/cdn/image/kn7m7u.png ' )
self . assertEqual ( meta [ ' og_url ' ] , ' https://maxbot.telefon-ip.ru/content/landing/2262/ ' )
self . assertEqual ( meta [ ' twitter_card ' ] , ' summary_large_image ' )
class LandingBotUrlsTests ( TestCase ) :
@patch ( ' content_bot.landing_utils.Integration ' )
@ -58,11 +87,13 @@ class LandingBotUrlsTests(TestCase):
qs . first . return_value = telegram_integration
else :
qs . first . return_value = None
qs . select_related . return_value = qs
return qs
mock_integration . objects . filter . side_effect = filter_side_effect
with patch ( ' content_bot.landing_utils._save_settings ' ) as mock_save :
with patch ( ' content_bot.landing_utils.cleanup_max_bot_integration ' ) , \
patch ( ' content_bot.landing_utils._save_settings ' ) as mock_save :
max_url , telegram_url = get_landing_bot_urls ( client )
self . assertEqual ( max_url , ' https://max.ru/d0323350531_bot ' )
@ -97,3 +128,7 @@ class LandingPageViewTests(TestCase):
self . assertEqual ( response . status_code , 200 )
self . assertContains ( response , ' https://max.ru/d0323350531_bot ' )
self . assertContains ( response , ' https://t.me/cheguevaraclub_bot ' )
self . assertContains ( response , ' property= " og:title " ' )
self . assertContains ( response , ' property= " og:description " ' )
self . assertContains ( response , ' property= " og:image " ' )
self . assertContains ( response , ' property= " og:url " ' )