

def sms_to_json(self, sms):
    '\n        Note: This method is very specific to the data of this test and\n        assumes that:\n            - the recipient is always self.contact1\n            - chat_user_id always points to self.chat_user if present\n            - the user requesting the chat history is always self.chat_user\n        '
    if (sms.direction == INCOMING):
        sender = 'test-case'
    elif sms.chat_user_id:
        sender = 'Sam'
    else:
        sender = 'System'
    return {
        'sender': sender,
        'text': sms.text,
        'timestamp': self.date.strftime('%I:%M%p %m/%d/%y').lower(),
        'utc_timestamp': json_format_datetime(sms.date),
        'sent_by_requester': (sms.chat_user_id is not None),
    }

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/tests/test_chat.py ChatHistoryTestCase.sms_to_json/VarMisuse@68/201 `sms`->`self`