def test_forum_random(conn: connection): text, user, avatar_url, date, url, desc = quotes.forum(conn, args=None) assert isinstance(date, dt.datetime) assert url.startswith(config.forum_url) assert "*" in text assert len(user) > 0 assert desc == " "
def test_forum_user(conn: connection): in_user = conftest.users[0] text, out_user, avatar_url, date, url, desc = quotes.forum( conn, args=[in_user.slack_nick]) assert isinstance(date, dt.datetime) assert url.startswith(config.forum_url) assert "*" in text assert out_user == in_user.slack_nick assert avatar_url.endswith(f"{in_user.id}.jpg") assert desc == " "
def cmd_forum(args: t.Optional[list[str]], conn: connection) -> dict: # no test coverage """if command is 'forum'""" text, user, avatar_url, date, url, description = quotes.forum(conn, args) pretty_date = prettify_date(date) text_block = {"type": "section", "text": {"type": "mrkdwn", "text": text}} context_block = { "type": "context", "elements": [ { "type": "image", "image_url": avatar_url, "alt_text": user }, { "type": "plain_text", "text": user }, { "type": "mrkdwn", "text": pretty_date }, { "type": "mrkdwn", "text": url }, { "type": "mrkdwn", "text": description }, ], } response = {"text": text, "blocks": [text_block, context_block]} return response
def test_forum_user_nonexistent(conn: connection): text, out_user, avatar_url, date, url, desc = quotes.forum( conn, args=["Non-existant user"]) assert desc == ( "Gargling not found: Non-existant user. Husk å bruke slack nick. " "Her er et tilfeldig quote i stedet.")