from datetime import datetime from uuid import UUID import arrow import pytest from mobilizon_reshare.dataclasses import MobilizonEvent from mobilizon_reshare.publishers.platforms.platform_mapping import get_formatter_class begin_date = arrow.get(datetime(year=2021, month=1, day=1, hour=11, minute=30,)) end_date = begin_date.shift(hours=1) @pytest.fixture() def event_to_format() -> MobilizonEvent: event = MobilizonEvent( name="test event", description="

description of the event

another header

", begin_datetime=begin_date, end_datetime=end_date, mobilizon_link="http://some_link.com/123", mobilizon_id=UUID(int=12345), thumbnail_link="http://some_link.com/123.jpg", location="location", last_update_time=begin_date, ) print("in fix", event.description, id(event)) return event @pytest.mark.parametrize( "publisher_name,expected_output", [ [ "facebook", f"""test event 🕒 01 January, {begin_date.format('HH:mm')} - 01 January, {end_date.format('HH:mm')} 📍 location description of the event another header 🔗 Link: http://some_link.com/123 """, ], [ "telegram", f"""test event 🕒 01 January, {begin_date.format('HH:mm')} - 01 January, {end_date.format('HH:mm')} 📍 location description of the event another header 🔗 Link""", ], ], ) def test_output_format( event_to_format: MobilizonEvent, publisher_name, expected_output ): assert ( get_formatter_class(publisher_name)() .get_message_from_event(event_to_format) .strip() == expected_output.strip() )