Example #1
0
def cmd_msn(args: t.Optional[t.List[str]], conn: connection) -> t.Dict:
    """if command is 'msn'"""
    date, text, description = quotes.msn(conn, args)

    response: t.Dict[str, t.Any] = {
        "text":
        date,
        "attachments": [{
            "color":
            msg_color,
            "blocks": [
                {
                    "type": "context",
                    "elements": [{
                        "type": "plain_text",
                        "text": msg_user + ":"
                    }],
                },
                {
                    "type": "section",
                    "text": {
                        "type": "mrkdwn",
                        "text": msg_text
                    }
                },
            ],
        } for msg_user, msg_text, msg_color in text],
    }
    if description:
        response["attachments"].append({"type": "mrkdwn", "text": description})
    return response
Example #2
0
def test_msn_user(conn: connection):
    user = conftest.users[0]
    date, conv, desc = quotes.msn(conn, args=[user.slack_nick])
    assert type(date) == str
    assert type(conv) == list
    assert desc is None
Example #3
0
def test_msn_user_nonexistent(conn: connection):
    date, conv, desc = quotes.msn(conn, args=["Non-existant user"])
    assert desc == (
        "Gargling not found: Non-existant user. Husk å bruke slack nick. "
        "Her er en tilfeldig samtale i stedet.")
Example #4
0
def test_msn_random(conn: connection):
    date, conv, desc = quotes.msn(conn, args=None)
    assert type(date) == str
    assert type(conv) == list
    assert desc is None