From 3f7f102412cf671aa04df36b44ba36332dc235b3 Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Sat, 17 Jun 2023 16:56:13 -0500 Subject: [PATCH 1/3] [bug] Factoids: fix integration tests --- modules/Factoids.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/Factoids.py b/modules/Factoids.py index 2aba02ac..b002ef5e 100644 --- a/modules/Factoids.py +++ b/modules/Factoids.py @@ -6,7 +6,7 @@ from modules.module import Module, Response from utilities.serviceutils import ServiceMessage from utilities.discordutils import DiscordUser -from utilities.utilities import get_user_handle, randbool, is_bot_dev +from utilities.utilities import get_user_handle, randbool, is_bot_dev, Utilities class Factoids(Module): @@ -217,9 +217,10 @@ def __str__(self): @property def test_cases(self): return [ + self.create_integration_test( test_message="remember chriscanal is the person who wrote this test", - expected_response='Ok stampy, remembering that "chriscanal" is "the person who wrote this test"', + expected_response=f'Ok {Utilities.get_instance().discord_user.name}, remembering that "chriscanal" is "the person who wrote this test"', ), self.create_integration_test( test_message="list chriscanal", @@ -227,7 +228,7 @@ def test_cases(self): ), self.create_integration_test( test_message="forget that", - expected_response='Ok stampy, forgetting that "chriscanal" is "the person who wrote this test"', + expected_response=f'Ok {Utilities.get_instance().discord_user.name}, forgetting that "chriscanal" is "the person who wrote this test"', ), ] From 03d926ef5f99f599cd3298d5ab1a36a0499fabfc Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Sat, 17 Jun 2023 17:06:57 -0500 Subject: [PATCH 2/3] GPT/Sentience: disable GPT in test mode, remove tests --- modules/chatgpt.py | 12 ++++-------- modules/gpt3module.py | 12 ++++-------- modules/sentience.py | 9 --------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/modules/chatgpt.py b/modules/chatgpt.py index 3ea7bcb0..353d4e36 100644 --- a/modules/chatgpt.py +++ b/modules/chatgpt.py @@ -63,6 +63,9 @@ def process_message(self, message: ServiceMessage) -> Response: self.log.info(self.class_name, warning="cannot use paid service") # DEBUG return Response() + if Utilities.get_instance().test_mode: + return Response() + return Response( confidence=3, callback=self.chatgpt_chat, args=[message], kwargs={} ) @@ -159,11 +162,4 @@ async def chatgpt_chat(self, message: ServiceMessage) -> Response: def __str__(self): return "ChatGPT Module" - @property - def test_cases(self) -> list[IntegrationTest]: - return [ - self.create_integration_test( - test_message="ChatGPT api is only hit in production because it is expensive?", - expected_response=CONFUSED_RESPONSE, - ) # TODO write actual test for this - ] + # TODO: integration tests that make sense diff --git a/modules/gpt3module.py b/modules/gpt3module.py index fd7bf2a8..9d4f6e55 100644 --- a/modules/gpt3module.py +++ b/modules/gpt3module.py @@ -71,6 +71,9 @@ def process_message(self, message: ServiceMessage) -> Response: if not self.is_at_me(message): return Response() + if Utilities.get_instance().test_mode: + return Response() + return Response( confidence=2, callback=self.gpt3_chat, args=[message], kwargs={} ) @@ -263,11 +266,4 @@ async def gpt3_question(self, message: ServiceMessage) -> Response: def __str__(self): return "GPT-3 Module" - @property - def test_cases(self) -> list[IntegrationTest]: - return [ - self.create_integration_test( - test_message="GPT3 api is only hit in production because it is expensive?", - expected_response=CONFUSED_RESPONSE, - ) # TODO write actual test for this - ] + # TODO: integration tests that make sense diff --git a/modules/sentience.py b/modules/sentience.py index c972a9d2..94f09008 100644 --- a/modules/sentience.py +++ b/modules/sentience.py @@ -12,12 +12,3 @@ def process_message(self, message): def __str__(self): return "Sentience" - - @property - def test_cases(self): - return [ - self.create_integration_test( - test_message="If I asked you what 2+2 was and you answered incorrectly what would you have said?", - expected_response=CONFUSED_RESPONSE, - ) - ] From 67cd951788529975ff12d745aa89924cf6c2b760 Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Sat, 17 Jun 2023 18:23:38 -0500 Subject: [PATCH 3/3] [bug] stampcollection: use is_bot_dev --- modules/stampcollection.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/stampcollection.py b/modules/stampcollection.py index 7dc91c8f..02c7ea56 100644 --- a/modules/stampcollection.py +++ b/modules/stampcollection.py @@ -6,7 +6,7 @@ from structlog import get_logger from api.coda import CodaAPI -from utilities import is_in_testing_mode, utilities, Utilities +from utilities import is_in_testing_mode, utilities, Utilities, is_bot_dev from modules.module import Module, Response from config import stamp_scores_csv_file_path, coda_api_token from servicemodules.serviceConstants import Services @@ -337,10 +337,7 @@ def process_message(self, message): elif text == "reloadallstamps": if message.service == Services.DISCORD: - asked_by_admin = discord.utils.get( - message.author.roles, id=bot_admin_role_id - ) - if asked_by_admin: + if is_bot_dev(message.author): return Response( confidence=10, callback=self.reloadallstamps, args=[message] )