def test_write_on_file():
    with TempDirectory() as d:
        d.write('jovem.json', b'')
        path = d.path + '/jovem.json'
        message = Message(path)

        message.add_message('chave', 'valor')
        assert json.loads("{\"chave\": [\"valor\"]}") == message.read_file()
        assert path == message.document_name
Example #2
0
def welcome_message(update, context):
    username = update.effective_user.username
    today = str(date.today())

    if not username:
        return

    message = Message(
            os.path.dirname(os.path.realpath('__file__')) +
            '/goodmorning_user.json'
    )

    if True is message.verify_exists(username, today):
        return

    message.add_message(username, today)

    context.bot.send_message(
            chat_id=update.effective_chat.id,
            text="Opa, tudo certo @{}? Como tá o seu dia?".format(username)
    )