Skip to content

Fix emoji tests

Fix emoji tests #1706

GitHub Actions / Pytest Results failed Nov 13, 2024 in 0s

27 tests run, 24 passed, 0 skipped, 3 failed.

Annotations

Check failure on line 508 in tests/test_bot.py

See this annotation in the file changed.

@github-actions github-actions / Pytest Results

test_bot.test_polls

AssertionError: assert [{'poll_media...ext': 'Two'}}] == [{'poll_media...ext': 'Two'}}]
  
  At index 0 diff: {'poll_media': {'text': 'One', 'emoji': {'name': '1️⃣', 'animated': False, 'available': True}}} != {'poll_media': {'text': 'One', 'emoji': {'name': '1️⃣', 'animated': False}}}
  
  Full diff:
    [
        {
            'poll_media': {
                'emoji': {
                    'animated': False,
  +                 'available': True,
                    'name': '1️⃣',
                },
                'text': 'One',
            },
        },
        {
            'poll_media': {
                'emoji': {
                    'animated': False,
  +                 'available': True,
                    'name': '2️⃣',
                },
                'text': 'Two',
            },
        },
    ]
Raw output
bot = <interactions.client.client.Client object at 0x7ffab4447520>
channel = GuildText(id=1306189424295673918, name='test_scene-fce63bc', type=<ChannelType.GUILD_TEXT: 0>)

    @pytest.mark.asyncio
    async def test_polls(bot: Client, channel: GuildText) -> None:
        msg = await channel.send("Polls Tests")
        thread = await msg.create_thread("Test Thread")
    
        try:
            poll_1 = Poll.create("Test Poll", duration=1, answers=["Answer 1", "Answer 2"])
            test_data_1 = {
                "question": {"text": "Test Poll"},
                "layout_type": 1,
                "duration": 1,
                "allow_multiselect": False,
                "answers": [{"poll_media": {"text": "Answer 1"}}, {"poll_media": {"text": "Answer 2"}}],
            }
            poll_1_dict = poll_1.to_dict()
            for key in poll_1_dict.keys():
                assert poll_1_dict[key] == test_data_1[key]
    
            msg_1 = await thread.send(poll=poll_1)
    
            assert msg_1.poll is not None
            assert msg_1.poll.question.to_dict() == PollMedia(text="Test Poll").to_dict()
            assert msg_1.poll.expiry <= msg_1.created_at + timedelta(hours=1, minutes=1)
            poll_1_answer_medias = [poll_answer.poll_media.to_dict() for poll_answer in msg_1.poll.answers]
            assert poll_1_answer_medias == [
                PollMedia.create(text="Answer 1").to_dict(),
                PollMedia.create(text="Answer 2").to_dict(),
            ]
    
            poll_2 = Poll.create("Test Poll 2", duration=1, allow_multiselect=True)
            poll_2.add_answer("Answer 1")
            poll_2.add_answer("Answer 2")
            test_data_2 = {
                "question": {"text": "Test Poll 2"},
                "layout_type": 1,
                "duration": 1,
                "allow_multiselect": True,
                "answers": [{"poll_media": {"text": "Answer 1"}}, {"poll_media": {"text": "Answer 2"}}],
            }
            poll_2_dict = poll_2.to_dict()
            for key in poll_2_dict.keys():
                assert poll_2_dict[key] == test_data_2[key]
            msg_2 = await thread.send(poll=poll_2)
    
            assert msg_2.poll is not None
            assert msg_2.poll.question.to_dict() == PollMedia(text="Test Poll 2").to_dict()
            assert msg_2.poll.expiry <= msg_2.created_at + timedelta(hours=1, minutes=1)
            assert msg_2.poll.allow_multiselect
            poll_2_answer_medias = [poll_answer.poll_media.to_dict() for poll_answer in msg_2.poll.answers]
            assert poll_2_answer_medias == [
                PollMedia.create(text="Answer 1").to_dict(),
                PollMedia.create(text="Answer 2").to_dict(),
            ]
    
            poll_3 = Poll.create(
                "Test Poll 3",
                duration=1,
                answers=[PollMedia.create(text="One", emoji="1️⃣"), PollMedia.create(text="Two", emoji="2️⃣")],
            )
            test_data_3 = {
                "question": {"text": "Test Poll 3"},
                "layout_type": 1,
                "duration": 1,
                "allow_multiselect": False,
                "answers": [
                    {"poll_media": {"text": "One", "emoji": {"name": "1️⃣", "animated": False}}},
                    {"poll_media": {"text": "Two", "emoji": {"name": "2️⃣", "animated": False}}},
                ],
            }
            poll_3_dict = poll_3.to_dict()
            for key in poll_3_dict.keys():
>               assert poll_3_dict[key] == test_data_3[key]
E               AssertionError: assert [{'poll_media...ext': 'Two'}}] == [{'poll_media...ext': 'Two'}}]
E                 
E                 At index 0 diff: {'poll_media': {'text': 'One', 'emoji': {'name': '1️⃣', 'animated': False, 'available': True}}} != {'poll_media': {'text': 'One', 'emoji': {'name': '1️⃣', 'animated': False}}}
E                 
E                 Full diff:
E                   [
E                       {
E                           'poll_media': {
E                               'emoji': {
E                                   'animated': False,
E                 +                 'available': True,
E                                   'name': '1️⃣',
E                               },
E                               'text': 'One',
E                           },
E                       },
E                       {
E                           'poll_media': {
E                               'emoji': {
E                                   'animated': False,
E                 +                 'available': True,
E                                   'name': '2️⃣',
E                               },
E                               'text': 'Two',
E                           },
E                       },
E                   ]

bot        = <interactions.client.client.Client object at 0x7ffab4447520>
channel    = GuildText(id=1306189424295673918, name='test_scene-fce63bc', type=<ChannelType.GUILD_TEXT: 0>)
key        = 'answers'
msg        = Message(id=1306189507023863871)
msg_1      = Message(id=1306189508798054473)
msg_2      = Message(id=1306189509339119646)
poll_1     = Poll()
poll_1_answer_medias = [{'text': 'Answer 1'}, {'text': 'Answer 2'}]
poll_1_dict = {'allow_multiselect': False, 'answers': [{'poll_media': {'text': 'Answer 1'}}, {'poll_media': {'text': 'Answer 2'}}], 'duration': 1, 'layout_type': <PollLayoutType.DEFAULT: 1>, ...}
poll_2     = Poll()
poll_2_answer_medias = [{'text': 'Answer 1'}, {'text': 'Answer 2'}]
poll_2_dict = {'allow_multiselect': True, 'answers': [{'poll_media': {'text': 'Answer 1'}}, {'poll_media': {'text': 'Answer 2'}}], 'duration': 1, 'layout_type': <PollLayoutType.DEFAULT: 1>, ...}
poll_3     = Poll()
poll_3_dict = {'allow_multiselect': False, 'answers': [{'poll_media': {'emoji': {'animated': False, 'available': True, 'name': '1️⃣'...e, 'available': True, 'name': '2️⃣'}, 'text': 'Two'}}], 'duration': 1, 'layout_type': <PollLayoutType.DEFAULT: 1>, ...}
test_data_1 = {'allow_multiselect': False, 'answers': [{'poll_media': {'text': 'Answer 1'}}, {'poll_media': {'text': 'Answer 2'}}], 'duration': 1, 'layout_type': 1, ...}
test_data_2 = {'allow_multiselect': True, 'answers': [{'poll_media': {'text': 'Answer 1'}}, {'poll_media': {'text': 'Answer 2'}}], 'duration': 1, 'layout_type': 1, ...}
test_data_3 = {'allow_multiselect': False, 'answers': [{'poll_media': {'emoji': {'animated': False, 'name': '1️⃣'}, 'text': 'One'}}, {'poll_media': {'emoji': {'animated': False, 'name': '2️⃣'}, 'text': 'Two'}}], 'duration': 1, 'layout_type': 1, ...}
thread     = GuildPublicThread(id=1306189507023863871, name='Test Thread', type=<ChannelType.GUILD_PUBLIC_THREAD: 11>)

tests/test_bot.py:508: AssertionError

Check failure on line 578 in tests/test_bot.py

See this annotation in the file changed.

@github-actions github-actions / Pytest Results

test_bot.test_voice

AssertionError: assert 231 != 231
 +  where 231 = <Player(Thread-4, stopped daemon 140714587448896)>._sent_payloads
 +    where <Player(Thread-4, stopped daemon 140714587448896)> = <ActiveVoiceState: channel=GuildVoice(id=1306189520353628220, name='_test_voice_two-fce63bc', type=<ChannelType.GUILD_VOICE: 2>) guild=Guild(id=1041449294022070292, name='NAFF Test Suite', description=None) volume=0.5 playing=False audio=<AudioVolume: tests/test_audio.mp3>>.player
Raw output
bot = <interactions.client.client.Client object at 0x7ffab4447520>
guild = Guild(id=1041449294022070292, name='NAFF Test Suite', description=None)

    @pytest.mark.asyncio
    async def test_voice(bot: Client, guild: Guild) -> None:
        test_channel = await guild.create_voice_channel(f"_test_voice-{bot.suffix}")
        test_channel_two = await guild.create_voice_channel(f"_test_voice_two-{bot.suffix}")
        try:
            try:
                import nacl  # noqa
            except ImportError:
                # testing on a non-voice extra
                return
    
            vc = await test_channel.connect(deafened=True)
            assert vc == bot.get_bot_voice_state(guild.id)
    
            audio = AudioVolume("tests/test_audio.mp3")
            vc.play_no_wait(audio)
            await asyncio.sleep(5)
    
            assert len(vc.current_audio.buffer) != 0
            assert vc.player._sent_payloads != 0
    
            await vc.move(test_channel_two)
            await asyncio.sleep(2)
    
            _before = vc.player._sent_payloads
    
            await test_channel_two.connect(deafened=True)
    
            await asyncio.sleep(2)
    
>           assert vc.player._sent_payloads != _before
E           AssertionError: assert 231 != 231
E            +  where 231 = <Player(Thread-4, stopped daemon 140714587448896)>._sent_payloads
E            +    where <Player(Thread-4, stopped daemon 140714587448896)> = <ActiveVoiceState: channel=GuildVoice(id=1306189520353628220, name='_test_voice_two-fce63bc', type=<ChannelType.GUILD_VOICE: 2>) guild=Guild(id=1041449294022070292, name='NAFF Test Suite', description=None) volume=0.5 playing=False audio=<AudioVolume: tests/test_audio.mp3>>.player

_before    = 231
audio      = <AudioVolume: tests/test_audio.mp3>
bot        = <interactions.client.client.Client object at 0x7ffab4447520>
guild      = Guild(id=1041449294022070292, name='NAFF Test Suite', description=None)
nacl       = <module 'nacl' from '/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/nacl/__init__.py'>
test_channel = GuildVoice(id=1306189519665631232, name='_test_voice-fce63bc', type=<ChannelType.GUILD_VOICE: 2>)
test_channel_two = GuildVoice(id=1306189520353628220, name='_test_voice_two-fce63bc', type=<ChannelType.GUILD_VOICE: 2>)
vc         = <ActiveVoiceState: channel=None guild=Guild(id=1041449294022070292, name='NAFF Test Suite', description=None) volume=0.5 playing=False audio=<AudioVolume: tests/test_audio.mp3>>

tests/test_bot.py:578: AssertionError

Check failure on line 1 in tests/test_bot.py

See this annotation in the file changed.

@github-actions github-actions / Pytest Results

test_bot.test_emoji

failed on teardown with "exceptiongroup.ExceptionGroup: errors while tearing down <Module test_bot.py> (2 sub-exceptions)"
Raw output
+ Exception Group Traceback (most recent call last):
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 341, in from_call
  |     result: TResult | None = func()
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 242, in <lambda>
  |     lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
  |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
  |     raise exception.with_traceback(exception.__traceback__)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
  |     teardown.throw(exception)  # type: ignore[union-attr]
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/threadexception.py", line 97, in pytest_runtest_teardown
  |     yield from thread_exception_runtest_hook()
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/threadexception.py", line 68, in thread_exception_runtest_hook
  |     yield
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
  |     teardown.throw(exception)  # type: ignore[union-attr]
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 100, in pytest_runtest_teardown
  |     yield from unraisable_exception_runtest_hook()
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 70, in unraisable_exception_runtest_hook
  |     yield
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
  |     teardown.throw(exception)  # type: ignore[union-attr]
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/logging.py", line 853, in pytest_runtest_teardown
  |     yield from self._runtest_for(item, "teardown")
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/logging.py", line 829, in _runtest_for
  |     yield
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 122, in _multicall
  |     teardown.throw(exception)  # type: ignore[union-attr]
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/capture.py", line 885, in pytest_runtest_teardown
  |     return (yield)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 189, in pytest_runtest_teardown
  |     item.session._setupstate.teardown_exact(nextitem)
  |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 557, in teardown_exact
  |     raise exceptions[0]
  | exceptiongroup.ExceptionGroup: errors while tearing down <Module test_bot.py> (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 546, in teardown_exact
    |     fin()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/fixtures.py", line 1032, in finish
    |     raise exceptions[0]
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/fixtures.py", line 1021, in finish
    |     fin()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 341, in finalizer
    |     event_loop.run_until_complete(async_finalizer())
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/base_events.py", line 624, in run_until_complete
    |     self._check_closed()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/base_events.py", line 515, in _check_closed
    |     raise RuntimeError('Event loop is closed')
    | RuntimeError: Event loop is closed
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/runner.py", line 546, in teardown_exact
    |     fin()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/fixtures.py", line 1032, in finish
    |     raise exceptions[0]
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/_pytest/fixtures.py", line 1021, in finish
    |     fin()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 341, in finalizer
    |     event_loop.run_until_complete(async_finalizer())
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/base_events.py", line 624, in run_until_complete
    |     self._check_closed()
    |   File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/asyncio/base_events.py", line 515, in _check_closed
    |     raise RuntimeError('Event loop is closed')
    | RuntimeError: Event loop is closed
    +------------------------------------