Fixed afk test #139
This commit is contained in:
parent
4bbcd387c6
commit
5beaf24bdc
@ -22,6 +22,7 @@
|
||||
"MePageUrl": "https://discord.com/channels/@me",
|
||||
"CmdURL": "https://discord.com/channels/910199451145076828/911578636899987526",
|
||||
"GuildId": 910199451145076828,
|
||||
"BotId": 998159802393964594
|
||||
"BotId": 998159802393964594,
|
||||
"TestUserId": 401941112010571777
|
||||
}
|
||||
}
|
@ -6,8 +6,8 @@ class CommandSelectorsEnum(Enum):
|
||||
cmd_chat_input = '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[3]/div/main/form/div/div[2]/div/div[2]/div/div'
|
||||
msg_input = '/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[1]/div/div[3]/div/div/div'
|
||||
|
||||
ping = '//*[ contains (text(), ‘Krümmelmonster-test’ ) ]'
|
||||
info = '//*[ contains (text(), ‘Krümmelmonster-test’ ) ]'
|
||||
help = '//*[ contains (text(), ‘Krümmelmonster-test’ ) ]'
|
||||
afk = '//*[ contains (text(), ‘Krümmelmonster-test’ ) ]'
|
||||
purge = '//*[ contains (text(), ‘Krümmelmonster-test’ ) ]'
|
||||
ping = '/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'
|
||||
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'
|
||||
|
@ -16,7 +16,12 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.10.0.post9"
|
||||
"cpl-core>=2022.10.0.post9",
|
||||
"PyNaCl==1.5.0",
|
||||
"cffi==1.15.1",
|
||||
"pycparser==2.21",
|
||||
"selenium==4.6.1",
|
||||
"webdriver-manager==3.8.5"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=2022.10.0"
|
||||
|
@ -14,6 +14,7 @@ class TestSettings(ConfigurationModelABC):
|
||||
self._cmd_url = ''
|
||||
self._guild_id = 0
|
||||
self._bot_id = 0
|
||||
self._test_user_id = 0
|
||||
|
||||
@property
|
||||
def login_url(self) -> str:
|
||||
@ -35,6 +36,10 @@ class TestSettings(ConfigurationModelABC):
|
||||
def bot_id(self) -> int:
|
||||
return self._bot_id
|
||||
|
||||
@property
|
||||
def test_user_id(self) -> int:
|
||||
return self._test_user_id
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._login_url = settings['LoginUrl']
|
||||
@ -42,6 +47,7 @@ class TestSettings(ConfigurationModelABC):
|
||||
self._cmd_url = settings['CmdURL']
|
||||
self._guild_id = settings['GuildId']
|
||||
self._bot_id = settings['BotId']
|
||||
self._test_user_id = settings['TestUserId']
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
|
@ -2,13 +2,14 @@ import asyncio
|
||||
|
||||
|
||||
class Async:
|
||||
_loop = None
|
||||
|
||||
@classmethod
|
||||
def async_func(cls, coro):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return asyncio.run(coro(*args, **kwargs))
|
||||
except Exception as e:
|
||||
return
|
||||
if cls._loop is None:
|
||||
cls._loop = asyncio.get_event_loop()
|
||||
|
||||
return cls._loop.run_until_complete(coro(*args, **kwargs))
|
||||
|
||||
return wrapper
|
||||
|
@ -21,7 +21,7 @@ class AFKCommandTestCase(CommandTestCaseWithApp):
|
||||
def check(m: discord.Message):
|
||||
return m.content == correct_response and m.author.id == self._test_settings.bot_id
|
||||
|
||||
response = await self._bot.wait_for('message', check=check)
|
||||
response = await self._bot.wait_for('message', check=check, timeout=10)
|
||||
self.assertEqual(response.content, correct_response)
|
||||
|
||||
@Async.async_func
|
||||
@ -29,15 +29,16 @@ class AFKCommandTestCase(CommandTestCaseWithApp):
|
||||
# correct_response = self._t.transform('modules.base.pong')
|
||||
# self.assertIsNotNone(correct_response)
|
||||
UI.driver.find_element(By.XPATH, '//*[@id="channels"]/ul/li[20]/div/div/div/a').click()
|
||||
time.sleep(1)
|
||||
def check1(member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
|
||||
return member.id == self._test_settings.test_user_id and after is not None and after.channel.id == 911578760476762153
|
||||
res = await self._bot.wait_for('voice_state_update', check=check1, timeout=10)
|
||||
|
||||
self.send_command('afk', CommandSelectorsEnum.afk)
|
||||
|
||||
def check(member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
|
||||
return member.id == self._bot.user.id
|
||||
|
||||
response: VoiceState = await self._bot.wait_for('voice_state_update', check=check)
|
||||
self.assertIsNotNone(response.channel)
|
||||
self.assertEqual(response.channel.id, 910199452915093594)
|
||||
# self.assertEqual(response.content, correct_response)
|
||||
def check2(member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
|
||||
return member.id == self._test_settings.test_user_id and after is not None and after.channel.id == 910199452915093594
|
||||
member, before, after = await self._bot.wait_for('voice_state_update', check=check2, timeout=10)
|
||||
UI.driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div/div[1]/section/div[1]/div/div[1]/div[2]/button').click()
|
||||
self.assertIsNotNone(after.channel)
|
||||
self.assertEqual(after.channel.id, 910199452915093594)
|
||||
# self.assertEqual(response.content, correct_response)
|
||||
|
Loading…
Reference in New Issue
Block a user