summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-05-31 09:22:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-06-10 02:07:23 +0300
commitf29e139cbb7e4a4d539cba6e894ef4a6acd312d6 (patch)
tree6246f126325c5c36fb573134a05f2771cd747966 /test
parent3e3753d726f8a02d98368f20f77dd9fa739e3d80 (diff)
WIP: big refactoring
Diffstat (limited to 'test')
-rwxr-xr-xtest/mqtt_relay_server_util.py17
-rwxr-xr-xtest/mqtt_relay_util.py38
-rwxr-xr-xtest/test_amixer.py2
-rwxr-xr-xtest/test_api.py2
-rwxr-xr-xtest/test_esp32_cam.py6
-rwxr-xr-xtest/test_inverter_monitor.py2
-rw-r--r--test/test_ipcam_server_cleanup.py2
-rwxr-xr-xtest/test_record_upload.py6
-rwxr-xr-xtest/test_send_fake_sound_hit.py4
-rwxr-xr-xtest/test_sound_server_api.py2
-rw-r--r--test/test_telegram_aio_send_photo.py2
11 files changed, 69 insertions, 14 deletions
diff --git a/test/mqtt_relay_server_util.py b/test/mqtt_relay_server_util.py
new file mode 100755
index 0000000..ac6a9ae
--- /dev/null
+++ b/test/mqtt_relay_server_util.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+import sys
+import os.path
+sys.path.extend([
+ os.path.realpath(
+ os.path.join(os.path.dirname(os.path.join(__file__)), '..')
+ )
+])
+
+from src.home.config import config
+from src.home.mqtt.relay import MQTTRelayClient
+
+
+if __name__ == '__main__':
+ config.load_app('test_mqtt_relay_server')
+ relay = MQTTRelayClient('test')
+ relay.connect_and_loop()
diff --git a/test/mqtt_relay_util.py b/test/mqtt_relay_util.py
new file mode 100755
index 0000000..0d8c764
--- /dev/null
+++ b/test/mqtt_relay_util.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+import sys
+import os.path
+sys.path.extend([
+ os.path.realpath(
+ os.path.join(os.path.dirname(os.path.join(__file__)), '..')
+ )
+])
+
+from argparse import ArgumentParser
+from src.home.config import config
+from src.home.mqtt.relay import MQTTRelayController
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('--on', action='store_true')
+ parser.add_argument('--off', action='store_true')
+ parser.add_argument('--stat', action='store_true')
+
+ config.load_app('test_mqtt_relay', parser=parser)
+ arg = parser.parse_args()
+
+ relay = MQTTRelayController('test')
+ relay.connect_and_loop(loop_forever=False)
+
+ if arg.on:
+ relay.set_power(True)
+
+ elif arg.off:
+ relay.set_power(False)
+
+ elif arg.stat:
+ relay.send_stat(dict(
+ state=False,
+ signal=-59,
+ fw_v=1.0
+ )) \ No newline at end of file
diff --git a/test/test_amixer.py b/test/test_amixer.py
index c8bd546..464941e 100755
--- a/test/test_amixer.py
+++ b/test/test_amixer.py
@@ -28,7 +28,7 @@ if __name__ == '__main__':
parser.add_argument('--decr', type=str)
# parser.add_argument('--dump-config', action='store_true')
- args = config.load('test_amixer', parser=parser)
+ args = config.load_app('test_amixer', parser=parser)
# if args.dump_config:
# print(config.data)
diff --git a/test/test_api.py b/test/test_api.py
index 1f6361c..e80eb4c 100755
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -13,7 +13,7 @@ from src.home.config import config
if __name__ == '__main__':
- config.load('test_api')
+ config.load_app('test_api')
api = WebAPIClient()
print(api.log_bot_request(BotType.ADMIN, 1, "test_api.py"))
diff --git a/test/test_esp32_cam.py b/test/test_esp32_cam.py
index 27ce379..6a4ad25 100755
--- a/test/test_esp32_cam.py
+++ b/test/test_esp32_cam.py
@@ -10,7 +10,7 @@ sys.path.extend([
from pprint import pprint
from argparse import ArgumentParser
from time import sleep
-from src.home.util import parse_addr
+from src.home.util import Addr
from src.home.camera import esp32
from src.home.config import config
@@ -21,8 +21,8 @@ if __name__ == '__main__':
parser.add_argument('--status', action='store_true',
help='print status and exit')
- arg = config.load(False, parser=parser)
- cam = esp32.WebClient(addr=parse_addr(arg.addr))
+ arg = config.load_app(False, parser=parser)
+ cam = esp32.WebClient(addr=Addr.fromstring(arg.addr))
if arg.status:
status = cam.getstatus()
diff --git a/test/test_inverter_monitor.py b/test/test_inverter_monitor.py
index 3b1c6b0..621c0e9 100755
--- a/test/test_inverter_monitor.py
+++ b/test/test_inverter_monitor.py
@@ -372,5 +372,5 @@ def main():
if __name__ == '__main__':
- config.load('test_inverter_monitor')
+ config.load_app('test_inverter_monitor')
main()
diff --git a/test/test_ipcam_server_cleanup.py b/test/test_ipcam_server_cleanup.py
index b7eb23a..5f313a4 100644
--- a/test/test_ipcam_server_cleanup.py
+++ b/test/test_ipcam_server_cleanup.py
@@ -77,5 +77,5 @@ def cleanup_job():
if __name__ == '__main__':
- config.load('ipcam_server')
+ config.load_app('ipcam_server')
cleanup_job()
diff --git a/test/test_record_upload.py b/test/test_record_upload.py
index cbd3ca2..835504f 100755
--- a/test/test_record_upload.py
+++ b/test/test_record_upload.py
@@ -13,7 +13,7 @@ import time
from src.home.api import WebAPIClient, RequestParams
from src.home.config import config
from src.home.media import SoundRecordClient
-from src.home.util import parse_addr
+from src.home.util import Addr
logger = logging.getLogger(__name__)
@@ -64,11 +64,11 @@ def api_success_handler(response, name, req: RequestParams):
if __name__ == '__main__':
- config.load('test_record_upload')
+ config.load_app('test_record_upload')
nodes = {}
for name, addr in config['nodes'].items():
- nodes[name] = parse_addr(addr)
+ nodes[name] = Addr(addr)
record = SoundRecordClient(nodes,
error_handler=record_error,
finished_handler=record_finished,
diff --git a/test/test_send_fake_sound_hit.py b/test/test_send_fake_sound_hit.py
index 9660c45..61886cd 100755
--- a/test/test_send_fake_sound_hit.py
+++ b/test/test_send_fake_sound_hit.py
@@ -8,7 +8,7 @@ sys.path.extend([
])
from argparse import ArgumentParser
-from src.home.util import send_datagram, stringify, parse_addr
+from src.home.util import send_datagram, stringify, Addr
if __name__ == '__main__':
@@ -22,4 +22,4 @@ if __name__ == '__main__':
args = parser.parse_args()
- send_datagram(stringify([args.name, args.hits]), parse_addr(args.server))
+ send_datagram(stringify([args.name, args.hits]), Addr.fromstring(args.server))
diff --git a/test/test_sound_server_api.py b/test/test_sound_server_api.py
index e68c6f8..5295a5d 100755
--- a/test/test_sound_server_api.py
+++ b/test/test_sound_server_api.py
@@ -56,7 +56,7 @@ def hits_sender():
if __name__ == '__main__':
- config.load('test_api')
+ config.load_app('test_api')
hc = HitCounter()
api = WebAPIClient()
diff --git a/test/test_telegram_aio_send_photo.py b/test/test_telegram_aio_send_photo.py
index 705e534..4d05c03 100644
--- a/test/test_telegram_aio_send_photo.py
+++ b/test/test_telegram_aio_send_photo.py
@@ -20,7 +20,7 @@ async def main():
if __name__ == '__main__':
- config.load('test_telegram_aio_send_photo')
+ config.load_app('test_telegram_aio_send_photo')
loop = asyncio.get_event_loop()
asyncio.ensure_future(main())