def test_from_dict(): now = datetime.now(timezone("Asia/Tokyo")) message = Message( id="mid123456789", type="hogehoge", timestamp=now, channel="TEST", channel_detail="messaging", channel_user_id="user_id", text="hello", token="token123456789", payloads=[Payload(content_type="image", url="https://image")], channel_message={"text": "hello"}) msg_dict = message.to_dict() message = Message.from_dict(msg_dict) assert message.id == "mid123456789" assert message.type == "hogehoge" assert message.timestamp == now assert message.channel == "TEST" assert message.channel_detail == "messaging" assert message.channel_user_id == "user_id" assert message.text == "hello" assert message.token == "token123456789" assert message.payloads[0].url == "https://image" assert message.channel_message == str({"text": "hello"})
def test_to_dict(): now = datetime.now(timezone("Asia/Tokyo")) message = Message( id="mid123456789", type="hogehoge", timestamp=now, channel="TEST", channel_detail="messaging", channel_user_id="user_id", text="hello", token="token123456789", payloads=[Payload(content_type="image", url="https://image")], channel_message={"text": "hello"}) msg_dict = message.to_dict() assert msg_dict["id"] == "mid123456789" assert msg_dict["timestamp"] == now