Skip to content
Merged

Devel #133

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion handlers/gpt_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
key = os.environ.get("OPENAI_API_KEY", "")
if key == "":
warnings.warn("Warning...........No OPENAI_API_KEY provided")
client = OpenAI(api_key=key)
client = OpenAI(api_key=key or "missing-openai-api-key")

DEFAULT_MODEL = "gpt-4.1"
DEFAULT_IMAGE_MODEL = "gpt-image-1-mini"
Expand Down
148 changes: 75 additions & 73 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,74 +1,76 @@
aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiosignal==1.3.2
annotated-types==0.7.0
anyio==4.7.0
APScheduler==3.11.0
async-timeout==5.0.1
attrs==24.3.0
beautifulsoup4==4.12.3
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.1
contourpy==1.3.1
cryptography==44.0.0
curl_cffi==0.14.0
cycler==0.12.1
dateparser==1.2.1
distro==1.9.0
exceptiongroup==1.2.2
ffmpeg-python==0.2.0
fonttools==4.55.3
frozendict==2.4.6
frozenlist==1.5.0
future==1.0.0
gitdb==4.0.11
GitPython==3.1.43
h11==0.14.0
html5lib==1.1
httpcore==1.0.7
httpx==0.28.1
idna==3.10
instaloader==4.14
jiter==0.12.0
kiwisolver==1.4.8
lxml==5.3.0
matplotlib==3.10.0
multidict==6.1.0
multitasking==0.0.11
numpy==2.2.1
openai==2.15.0
packaging==24.2
pandas==2.2.3
peewee==3.17.8
phonenumbers==9.0.0
pillow==11.0.0
platformdirs==4.3.6
propcache==0.2.1
pycparser==2.22
aiohappyeyeballs==2.7.1
aiohttp==3.14.1
aiosignal==1.4.0
annotated-types==0.7.0
anyio==4.14.1
APScheduler==3.11.3
async-timeout==5.0.1
attrs==26.1.0
beautifulsoup4==4.15.0
certifi==2026.6.17
cffi==2.0.0
charset-normalizer==3.4.7
contourpy==1.3.2
cryptography==49.0.0
curl_cffi==0.15.0
cycler==0.12.1
dateparser==1.4.1
distro==1.9.0
exceptiongroup==1.3.1
ffmpeg-python==0.2.0
fonttools==4.63.0
frozendict==2.4.7
frozenlist==1.8.0
future==1.0.0
gitdb==4.0.12
GitPython==3.1.50
h11==0.16.0
html5lib==1.1
httpcore==1.0.9
httpx==0.28.1
idna==3.18
instaloader==4.15.1
jiter==0.16.0
kiwisolver==1.5.0
lxml==6.1.1
matplotlib==3.10.9
multidict==6.7.1
multitasking==0.0.13
numpy==2.2.6
openai==2.44.0
packaging==26.2
pandas==2.3.3
peewee==4.1.1
phonenumbers==9.0.33
pillow==12.3.0
platformdirs==4.10.0
propcache==0.5.2
pycparser==3.0
py-mini-racer==0.6.0
pydantic==2.10.4
pydantic_core==2.27.2
pyparsing==3.2.0
python-dateutil==2.9.0.post0
pytubefix==8.8.5
pytz==2024.2
redis==4.6.0
redvid==2.0.6
regex==2026.1.15
requests==2.32.3
signalbot==0.10.1
six==1.17.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.6
tqdm==4.67.1
typing_extensions==4.12.2
tzdata==2024.2
tzlocal==5.2
urllib3==2.3.0
webencodings==0.5.1
websockets==10.4
yarl==1.18.3
yfinance==0.2.58
yt-dlp==2026.3.17
PyYAML==6.0.3
pydantic==2.13.4
pydantic_core==2.46.4
pyparsing==3.3.2
pytest==9.1.1
pytest-mock==3.15.1
python-dateutil==2.9.0.post0
pytubefix==10.10.1
pytz==2026.2
redis==8.0.1
redvid==2.0.6
regex==2026.6.28
requests==2.34.2
six==1.17.0
smmap==5.0.3
sniffio==1.3.1
soupsieve==2.8.4
tqdm==4.68.3
typing_extensions==4.15.0
tzdata==2026.2
tzlocal==5.4.4
urllib3==2.7.0
webencodings==0.5.1
websockets==16.0
yarl==1.24.2
yfinance==1.5.1
yt-dlp==2026.7.1.235203.dev0
12 changes: 6 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
# method 1 (windows)
current_dir = os.path.abspath(__file__)
current_dir = os.path.dirname(current_dir)
path_to_append = os.path.join(current_dir, "./signalbot_local/")
path_to_append = os.path.join(current_dir, "./signalbot_local/src/")
if os.path.exists(path_to_append):
sys.path.append(path_to_append)
print(f"Appended {path_to_append} to sys.path")
sys.path.insert(0, path_to_append)
print(f"Prepended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

# method 2 (linux)
path_to_append = os.path.join(os.getcwd(), "./signalbot_local/")
path_to_append = os.path.join(os.getcwd(), "./signalbot_local/src/")
if os.path.exists(path_to_append):
sys.path.append(path_to_append)
print(f"Appended {path_to_append} to sys.path")
sys.path.insert(0, path_to_append)
print(f"Prepended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

Expand Down
61 changes: 34 additions & 27 deletions tests/TurboTestCase.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# allow importing of local signalbot
import sys
import os
current_dir = os.path.abspath(__file__)
current_dir = os.path.dirname(current_dir)
path_to_append = os.path.join(current_dir, "../signalbot_local/")
if os.path.exists(path_to_append):
sys.path.append(path_to_append)
print(f"Appended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

import unittest
from unittest.mock import patch
import logging
from signalbot import SignalBot, Command, Context, triggered
from signalbot.utils import chat, ChatTestCase, SendMessagesMock, ReceiveMessagesMock
from run import TurboBotCommand, LOGMSG


class TurboTestCase(ChatTestCase):
def setUp(self):
super().setUp()
group = {"id": "asdf", "name": "Test"}
self.signal_bot._groups_by_internal_id = {"group_id1=": group}
self.signal_bot.groups = [{"internal_id": "group_id1=", "name": "fake group"}]
self.signal_bot.register(TurboBotCommand(), contacts=True, groups=True)
# allow importing of local signalbot
import sys
import os
current_dir = os.path.abspath(__file__)
current_dir = os.path.dirname(current_dir)
path_to_append = os.path.join(current_dir, "../signalbot_local/src/")
if os.path.exists(path_to_append):
sys.path.insert(0, path_to_append)
print(f"Prepended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

import unittest
from unittest.mock import AsyncMock, patch
import logging
from signalbot import SignalBot, Command, Context, triggered
from signalbot.utils import mock_chat as chat, ChatTestCase, SendMessagesMock, ReceiveMessagesMock
from run import TurboBotCommand, LOGMSG


class TurboTestCase(unittest.IsolatedAsyncioTestCase, ChatTestCase):
async def asyncSetUp(self):
await super().asyncSetUp()
self.setup()
group = {
"id": ChatTestCase.group_id,
"internal_id": ChatTestCase.group_internal_id,
"name": ChatTestCase.group_name,
}
self.signal_bot._signal.get_groups = AsyncMock(return_value=[group])
self.signal_bot._groups_by_internal_id = {ChatTestCase.group_internal_id: group}
self.signal_bot.groups = [group]
self.signal_bot.register(TurboBotCommand(), contacts=True, groups=True)
await self.signal_bot._resolve_commands()
77 changes: 41 additions & 36 deletions tests/test_asteroid.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
# allow importing of local signalbot
import sys
import os
from tests.TurboTestCase import TurboTestCase
current_dir = os.path.abspath(__file__)
current_dir = os.path.dirname(current_dir)
path_to_append = os.path.join(current_dir, "../signalbot_local/")
if os.path.exists(path_to_append):
sys.path.append(path_to_append)
print(f"Appended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

import unittest
from unittest.mock import patch
import logging
from TurboTestCase import TurboTestCase
from signalbot import Command, Context, triggered
from signalbot.utils import chat, ChatTestCase, SendMessagesMock, ReceiveMessagesMock
from run import TurboBotCommand, LOGMSG

class AsteroidTest(TurboTestCase):
def setUp(self):
super().setUp()

@patch("signalbot.SignalAPI.send", new_callable=SendMessagesMock)
@patch("signalbot.SignalAPI.receive", new_callable=ReceiveMessagesMock)
async def test_Asteroid(self, receive_mock, send_mock):
receive_mock.define(["#asteroid"])
await self.run_bot()
self.assertEqual(send_mock.call_count, 1)
self.assertEqual( "exception" in send_mock.call_args_list[0].args[1], False )
print(send_mock.call_args_list[0].args[1])

if __name__ == "__main__":
unittest.main()
# allow importing of local signalbot
import sys
import os
from tests.TurboTestCase import TurboTestCase
current_dir = os.path.abspath(__file__)
current_dir = os.path.dirname(current_dir)
path_to_append = os.path.join(current_dir, "../signalbot_local/src/")
if os.path.exists(path_to_append):
sys.path.insert(0, path_to_append)
print(f"Prepended {path_to_append} to sys.path")
else:
print(f"Path {path_to_append} does not exist")

import unittest
from unittest.mock import patch
import logging
from TurboTestCase import TurboTestCase
from signalbot import Command, Context, triggered
from signalbot.utils import mock_chat as chat, ChatTestCase, SendMessagesMock, ReceiveMessagesMock
from run import TurboBotCommand, LOGMSG

class AsteroidTest(TurboTestCase):
def setUp(self):
super().setUp()

@patch("signalbot.SignalAPI.send", new_callable=SendMessagesMock)
@patch("signalbot.SignalAPI.receive", new_callable=ReceiveMessagesMock)
async def test_Asteroid(self, receive_mock, send_mock):
with patch(
"handlers.asteroid_handler.get_impact_probability",
return_value="No impact probability data found for 2024 YR4",
):
receive_mock.define(["#asteroid"])
await self.run_bot()

self.assertEqual(send_mock.call_count, 1)
self.assertEqual( "exception" in send_mock.call_args_list[0].args[1], False )
print(send_mock.call_args_list[0].args[1])

if __name__ == "__main__":
unittest.main()
Loading
Loading