From 5efcddf98336c59a5a4e491312a118ddd5040426 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 27 Nov 2022 16:08:35 +0100 Subject: [PATCH] Fixed purge test #139 --- .../test/ui_tests/src/ui_tests_shared/__init__.py | 1 - .../ui_tests_shared/command_selectors_enum.py | 2 +- .../ui_tests_shared/command_test_case_with_app.py | 2 +- .../commands/common/afk_command_test_case.py | 5 +---- .../commands/common/help_command_test_case.py | 2 +- .../commands/common/info_command_test_case.py | 2 +- .../commands/common/ping_command_test_case.py | 2 +- .../commands/common/purge_command_test_case.py | 13 ++++++++----- 8 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 kdb-bot/test/ui_tests/src/ui_tests_shared/__init__.py rename kdb-bot/test/{ui_tests/src => }/ui_tests_shared/command_selectors_enum.py (94%) diff --git a/kdb-bot/test/ui_tests/src/ui_tests_shared/__init__.py b/kdb-bot/test/ui_tests/src/ui_tests_shared/__init__.py deleted file mode 100644 index 425ab6c1..00000000 --- a/kdb-bot/test/ui_tests/src/ui_tests_shared/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# imports diff --git a/kdb-bot/test/ui_tests/src/ui_tests_shared/command_selectors_enum.py b/kdb-bot/test/ui_tests_shared/command_selectors_enum.py similarity index 94% rename from kdb-bot/test/ui_tests/src/ui_tests_shared/command_selectors_enum.py rename to kdb-bot/test/ui_tests_shared/command_selectors_enum.py index 992b90e0..a9eceaf7 100644 --- a/kdb-bot/test/ui_tests/src/ui_tests_shared/command_selectors_enum.py +++ b/kdb-bot/test/ui_tests_shared/command_selectors_enum.py @@ -10,4 +10,4 @@ class CommandSelectorsEnum(Enum): info = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div[2]/main/form/div/div[2]/div/div/div[5]/div' help = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div[2]/main/form/div/div[2]/div/div/div[5]/div' afk = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div[2]/main/form/div/div[2]/div/div/div[2]/div' - purge = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div[2]/main/form/div/div[2]/div/div/div[5]/div' + purge = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div[2]/main/form/div/div[2]/div/div/div[3]/div' diff --git a/kdb-bot/test/ui_tests_shared/command_test_case_with_app.py b/kdb-bot/test/ui_tests_shared/command_test_case_with_app.py index ae5a88d4..93fe4853 100644 --- a/kdb-bot/test/ui_tests_shared/command_test_case_with_app.py +++ b/kdb-bot/test/ui_tests_shared/command_test_case_with_app.py @@ -10,7 +10,7 @@ from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.test_case_with_app import TestCaseWithApp from ui_tests_shared.ui import UI diff --git a/kdb-bot/test/ui_tests_tests/commands/common/afk_command_test_case.py b/kdb-bot/test/ui_tests_tests/commands/common/afk_command_test_case.py index 69558e62..86bab1c9 100644 --- a/kdb-bot/test/ui_tests_tests/commands/common/afk_command_test_case.py +++ b/kdb-bot/test/ui_tests_tests/commands/common/afk_command_test_case.py @@ -1,10 +1,7 @@ -import time - import discord -from discord import VoiceState from selenium.webdriver.common.by import By -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.command_test_case_with_app import CommandTestCaseWithApp from ui_tests_shared.decorators import Async from ui_tests_shared.ui import UI diff --git a/kdb-bot/test/ui_tests_tests/commands/common/help_command_test_case.py b/kdb-bot/test/ui_tests_tests/commands/common/help_command_test_case.py index 844b4109..78bf5580 100644 --- a/kdb-bot/test/ui_tests_tests/commands/common/help_command_test_case.py +++ b/kdb-bot/test/ui_tests_tests/commands/common/help_command_test_case.py @@ -1,6 +1,6 @@ import discord -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.command_test_case_with_app import CommandTestCaseWithApp from ui_tests_shared.decorators import Async diff --git a/kdb-bot/test/ui_tests_tests/commands/common/info_command_test_case.py b/kdb-bot/test/ui_tests_tests/commands/common/info_command_test_case.py index 02b100dc..36c1e56e 100644 --- a/kdb-bot/test/ui_tests_tests/commands/common/info_command_test_case.py +++ b/kdb-bot/test/ui_tests_tests/commands/common/info_command_test_case.py @@ -3,7 +3,7 @@ import discord import bot from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.command_test_case_with_app import CommandTestCaseWithApp from ui_tests_shared.decorators import Async diff --git a/kdb-bot/test/ui_tests_tests/commands/common/ping_command_test_case.py b/kdb-bot/test/ui_tests_tests/commands/common/ping_command_test_case.py index a66213d4..e0553742 100644 --- a/kdb-bot/test/ui_tests_tests/commands/common/ping_command_test_case.py +++ b/kdb-bot/test/ui_tests_tests/commands/common/ping_command_test_case.py @@ -1,6 +1,6 @@ import discord -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.command_test_case_with_app import CommandTestCaseWithApp from ui_tests_shared.decorators import Async diff --git a/kdb-bot/test/ui_tests_tests/commands/common/purge_command_test_case.py b/kdb-bot/test/ui_tests_tests/commands/common/purge_command_test_case.py index 76106c3c..efdb5bd1 100644 --- a/kdb-bot/test/ui_tests_tests/commands/common/purge_command_test_case.py +++ b/kdb-bot/test/ui_tests_tests/commands/common/purge_command_test_case.py @@ -1,9 +1,8 @@ -import asyncio import time import discord -from ui_tests.src.ui_tests_shared.command_selectors_enum import CommandSelectorsEnum +from ui_tests_shared.command_selectors_enum import CommandSelectorsEnum from ui_tests_shared.command_test_case_with_app import CommandTestCaseWithApp from ui_tests_shared.decorators import Async @@ -16,7 +15,8 @@ class PurgeCommandTestCase(CommandTestCaseWithApp): self.send_message('test nachricht 3') self.send_message('test nachricht 4') - def test_purge(self): + @Async.async_func + async def test_purge(self): correct_response = self._t.transform('modules.moderator.purge_message') self.assertIsNotNone(correct_response) self.send_command('purge', CommandSelectorsEnum.purge) @@ -24,8 +24,11 @@ class PurgeCommandTestCase(CommandTestCaseWithApp): def check(m: discord.Message): return m.content == correct_response and m.author.id == self._test_settings.bot_id - response = asyncio.run(self._bot.wait_for('message', check=check)) + response = await self._bot.wait_for('message', check=check) self.assertEqual(response.content, correct_response) time.sleep(20) channel = self._bot.get_channel(911578680998895687) - self.assertEqual(channel.message_count, 0) + message_count = 0 + async for _ in channel.history(limit=None): + message_count += 1 + self.assertEqual(message_count, 0)