def test_get_commands_globally_call_invalid_incoming(dispike_object: Dispike): respx.get(f"https://discord.com/api/v8/applications/APPID/commands").mock( return_value=Response( 200, json=[ { "id": "1234", "application_id": "7890", "name": "mccoolbotv1", "options": [{ "type": 6, "name": "wave", "description": "wave at a person" }], }, { "id": "3344", "application_id": "7890", "description": "send a message", "options": [{ "type": 3, "name": "message", "description": "send a message" }], }, ], )) with pytest.raises(ValidationError): _get_commands = dispike_object.get_commands()
def test_get_commands_guild_only_call_successful(dispike_object: Dispike): respx.get( "https://discord.com/api/v8/applications/APPID/guilds/EXAMPLE_GUILD/commands" ).mock(return_value=Response( 200, json=[ { "id": "1234", "application_id": "7890", "name": "mccoolbotv1", "description": "McCoolbot is the coolest bot around.", "options": [{ "type": 6, "name": "wave", "description": "wave at a person" }], }, { "id": "3344", "application_id": "7890", "name": "mccoolbotv2", "description": "send a message", "options": [{ "type": 3, "name": "message", "description": "send a message" }], }, ], )) _get_commands = dispike_object.get_commands( guild_only=True, guild_id_passed="EXAMPLE_GUILD") for item in _get_commands: assert isinstance(item, IncomingApplicationCommand) == True assert len(_get_commands) == 2
def test_get_commands_guild_only_call_fail(dispike_object: Dispike): respx.get( "https://discord.com/api/v8/applications/APPID/guilds/EXAMPLE_GUILD/commands" ).mock(return_value=Response( 404, json=[ { "id": "1234", "application_id": "7890", "name": "mccoolbotv1", "description": "McCoolbot is the coolest bot around.", "options": [{ "type": 6, "name": "wave", "description": "wave at a person" }], }, { "id": "3344", "application_id": "7890", "name": "mccoolbotv2", "description": "send a message", "options": [{ "type": 3, "name": "message", "description": "send a message" }], }, ], )) with pytest.raises(DiscordAPIError): _get_commands = dispike_object.get_commands( guild_only=True, guild_id_passed="EXAMPLE_GUILD")
def test_get_commands_invalid_guild_id_passed(dispike_object: Dispike): with pytest.raises(TypeError): dispike_object.get_commands(guild_only=True)