def test_no_username_set(context, requests_mock):
    username = ""
    update = MockTelegramUpdate.with_inline_query(query=f"favs:{username}")
    inline = InlineFunctionality(MockExportAPI())
    # mock export api doesn't do non-existent users, so mocking with requests
    inline.api = FAExportAPI("http://example.com")
    requests_mock.get(
        f"http://example.com/user/{username}/favorites.json?page=1&full=1",
        json={
            "id": None,
            "name": "favorites",
            "profile": "https://www.furaffinity.net/user/favorites/"
        })

    inline.call(update, context)

    context.bot.answer_inline_query.assert_called_once()
    args = context.bot.answer_inline_query.call_args[0]
    assert context.bot.answer_inline_query.call_args[1]['next_offset'] == ""
    assert args[0] == update.inline_query.id
    assert isinstance(args[1], list)
    assert len(args[1]) == 1
    assert isinstance(args[1][0], InlineQueryResultArticle)
    assert args[1][0].title == "User does not exist."
    assert isinstance(args[1][0].input_message_content, InputMessageContent)
    assert args[1][0].input_message_content.message_text == \
           f"FurAffinity user does not exist by the name: \"{username}\"."
def test_username_with_colon(context, requests_mock):
    # FA doesn't allow usernames to have : in them
    username = "******"
    update = MockTelegramUpdate.with_inline_query(query=f"gallery:{username}")
    inline = InlineFunctionality(MockExportAPI())
    # mock export api doesn't do non-existent users, so mocking with requests
    inline.api = FAExportAPI("http://example.com")
    requests_mock.get(
        f"http://example.com/user/{username}/gallery.json",
        status_code=404
    )

    inline.call(update, context)

    context.bot.answer_inline_query.assert_called_once()
    args = context.bot.answer_inline_query.call_args[0]
    assert context.bot.answer_inline_query.call_args[1]['next_offset'] == ""
    assert args[0] == update.inline_query.id
    assert isinstance(args[1], list)
    assert len(args[1]) == 1
    assert isinstance(args[1][0], InlineQueryResultArticle)
    assert args[1][0].title == "User does not exist."
    assert isinstance(args[1][0].input_message_content, InputMessageContent)
    assert args[1][0].input_message_content.message_text == \
           f"FurAffinity user does not exist by the name: \"{username}\"."