tests.mocks.build_voice_channel

Here are the examples of the python api tests.mocks.build_voice_channel taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

0 Source : test_lfg_cog.py
with MIT License
from lexicalunit

    async def test_join_happy_path(self):
        assert self.ctx.guild
        assert self.ctx.author
        assert isinstance(self.ctx.author, discord.User)
        guild = ctx_guild(self.ctx, voice_create=True)
        channel = ctx_channel(self.ctx, guild)
        game = ctx_game(self.ctx, guild, channel, seats=2)
        other_user = ctx_user(self.ctx, xid=self.ctx.author_id + 1, game=game)
        other_player = mock_discord_user(other_user)

        with mock_operations(lfg_interaction, users=[self.ctx.author, other_player]):
            lfg_interaction.safe_get_partial_message.return_value = self.ctx.message
            voice_channel = build_voice_channel(self.ctx.guild)
            lfg_interaction.safe_create_voice_channel.return_value = voice_channel
            lfg_interaction.safe_create_invite.return_value = "http://invite"

            cog = LookingForGameCog(self.bot)
            await cog.join.func(cog, self.ctx)

        found = DatabaseSession.query(Game).one()
        assert found.voice_xid == voice_channel.id
        assert found.voice_invite_link == "http://invite"

    async def test_join_when_category_fails(self):

0 Source : test_lfg_cog.py
with MIT License
from lexicalunit

    async def test_join_when_invite_fails(self):
        assert self.ctx.guild
        assert self.ctx.author
        assert isinstance(self.ctx.author, discord.User)
        guild = ctx_guild(self.ctx, voice_create=True)
        channel = ctx_channel(self.ctx, guild)
        game = ctx_game(self.ctx, guild, channel, seats=2)
        other_user = ctx_user(self.ctx, xid=self.ctx.author_id + 1, game=game)
        other_player = mock_discord_user(other_user)

        with mock_operations(lfg_interaction, users=[self.ctx.author, other_player]):
            lfg_interaction.safe_get_partial_message.return_value = self.ctx.message
            voice_channel = build_voice_channel(self.ctx.guild)
            lfg_interaction.safe_create_voice_channel.return_value = voice_channel
            lfg_interaction.safe_create_invite.return_value = None

            cog = LookingForGameCog(self.bot)
            await cog.join.func(cog, self.ctx)

        found = DatabaseSession.query(Game).one()
        assert found.voice_xid == voice_channel.id
        assert not found.voice_invite_link