summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-09-27 00:54:57 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-09-27 00:54:57 +0300
commitd3a295872c49defb55fc8e4e43e55550991e0927 (patch)
treeb9dca15454f9027d5a9dad0d4443a20de04dbc5d /test
parentb7cbc2571c1870b4582ead45277d0aa7f961bec8 (diff)
parentbdbb296697f55f4c3a07af43c9aaf7a9ea86f3d0 (diff)
Merge branch 'master' of ch1p.io:homekit
Diffstat (limited to 'test')
-rw-r--r--test/__init__.py0
-rw-r--r--test/__py_include.py9
-rwxr-xr-xtest/mqtt_relay_server_util.py11
-rwxr-xr-xtest/mqtt_relay_util.py32
-rwxr-xr-xtest/test.py7
-rwxr-xr-xtest/test_amixer.py11
-rwxr-xr-xtest/test_api.py19
-rwxr-xr-xtest/test_esp32_cam.py18
-rwxr-xr-xtest/test_inverter_monitor.py21
-rw-r--r--test/test_ipcam_server_cleanup.py16
-rwxr-xr-xtest/test_polaris_stuff.py11
-rwxr-xr-xtest/test_record_upload.py23
-rwxr-xr-xtest/test_send_fake_sound_hit.py12
-rwxr-xr-xtest/test_sensors_plot.py0
-rwxr-xr-xtest/test_sound_node_client.py9
-rwxr-xr-xtest/test_sound_server_api.py18
-rwxr-xr-xtest/test_stopwatch.py3
-rw-r--r--test/test_telegram_aio_send_photo.py15
18 files changed, 106 insertions, 129 deletions
diff --git a/test/__init__.py b/test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/test/__init__.py
+++ /dev/null
diff --git a/test/__py_include.py b/test/__py_include.py
new file mode 100644
index 0000000..8f98830
--- /dev/null
+++ b/test/__py_include.py
@@ -0,0 +1,9 @@
+import sys
+import os.path
+
+for _name in ('include/py',):
+ sys.path.extend([
+ os.path.realpath(
+ os.path.join(os.path.dirname(os.path.join(__file__)), '..', _name)
+ )
+ ]) \ No newline at end of file
diff --git a/test/mqtt_relay_server_util.py b/test/mqtt_relay_server_util.py
new file mode 100755
index 0000000..6c02d75
--- /dev/null
+++ b/test/mqtt_relay_server_util.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+import __py_include
+
+from homekit.config import config
+
+
+if __name__ == '__main__':
+ print(config)
+ # 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..394bbe8
--- /dev/null
+++ b/test/mqtt_relay_util.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+import __py_include
+
+from argparse import ArgumentParser
+from homekit.config import config
+from homekit.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.py b/test/test.py
deleted file mode 100755
index 7ea37e6..0000000
--- a/test/test.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-from home.relay import RelayClient
-
-
-if __name__ == '__main__':
- c = RelayClient()
- print(c, c._host) \ No newline at end of file
diff --git a/test/test_amixer.py b/test/test_amixer.py
index c8bd546..e4abc73 100755
--- a/test/test_amixer.py
+++ b/test/test_amixer.py
@@ -1,12 +1,9 @@
#!/usr/bin/env python3
-import sys, os.path
-sys.path.extend([
- os.path.realpath(os.path.join(os.path.dirname(os.path.join(__file__)), '..')),
-])
+import __py_include
from argparse import ArgumentParser
-from src.home.config import config
-from src.home.audio import amixer
+from homekit.config import config
+from homekit.audio import amixer
def validate_control(input: str):
@@ -28,7 +25,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..b35a597 100755
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -1,19 +1,12 @@
#!/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__)), '..')
- )
-])
+import __py_include
-from src.home.api import WebAPIClient
-from src.home.api.types import BotType
-from src.home.config import config
+from homekit.api import WebApiClient
+from homekit.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"))
+ # 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..962768f 100755
--- a/test/test_esp32_cam.py
+++ b/test/test_esp32_cam.py
@@ -1,18 +1,12 @@
#!/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__)), '..')
- )
-])
+import __py_include
from pprint import pprint
from argparse import ArgumentParser
from time import sleep
-from src.home.util import parse_addr
-from src.home.camera import esp32
-from src.home.config import config
+from homekit.util import Addr
+from homekit.camera import esp32
+from homekit.config import config
if __name__ == '__main__':
parser = ArgumentParser()
@@ -21,8 +15,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..3231bab 100755
--- a/test/test_inverter_monitor.py
+++ b/test/test_inverter_monitor.py
@@ -1,22 +1,11 @@
#!/usr/bin/env python3
-import cmd
-import time
-import logging
-import socket
-import sys
-import threading
-import os.path
-sys.path.extend([
- os.path.realpath(
- os.path.join(os.path.dirname(os.path.join(__file__)), '..')
- )
-])
+import __py_include
from enum import Enum, auto
from typing import Optional
-from src.home.util import stringify
-from src.home.config import config
-from src.home.inverter import (
+from homekit.util import stringify
+from homekit.config import config
+from homekit.inverter import (
wrapper_instance as inverter,
InverterMonitor,
@@ -372,5 +361,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..ae8d31c 100644
--- a/test/test_ipcam_server_cleanup.py
+++ b/test/test_ipcam_server_cleanup.py
@@ -1,19 +1,13 @@
#!/usr/bin/env python3
-import shutil
-import sys
+import __py_include
+import logging
import os
+import shutil
import re
-import logging
-sys.path.extend([
- os.path.realpath(
- os.path.join(os.path.dirname(os.path.join(__file__)), '..')
- )
-])
from functools import cmp_to_key
from datetime import datetime
-from pprint import pprint
-from src.home.config import config
+from homekit.config import config
logger = logging.getLogger(__name__)
@@ -77,5 +71,5 @@ def cleanup_job():
if __name__ == '__main__':
- config.load('ipcam_server')
+ config.load_app('ipcam_server')
cleanup_job()
diff --git a/test/test_polaris_stuff.py b/test/test_polaris_stuff.py
index b921891..7778667 100755
--- a/test/test_polaris_stuff.py
+++ b/test/test_polaris_stuff.py
@@ -1,13 +1,6 @@
#!/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__)), '..')
- )
-])
-
-import src.syncleo as polaris
+import __py_include
+import syncleo
if __name__ == '__main__':
diff --git a/test/test_record_upload.py b/test/test_record_upload.py
index cbd3ca2..f9c83d8 100755
--- a/test/test_record_upload.py
+++ b/test/test_record_upload.py
@@ -1,19 +1,12 @@
#!/usr/bin/env python3
+import __py_include
import logging
-import sys
-import os.path
-sys.path.extend([
- os.path.realpath(
- os.path.join(os.path.dirname(os.path.join(__file__)), '..')
- )
-])
-
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 homekit.api import WebApiClient, RequestParams
+from homekit.config import config
+from homekit.media import SoundRecordClient
+from homekit.util import Addr
logger = logging.getLogger(__name__)
@@ -64,17 +57,17 @@ 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,
download_on_finish=True)
- api = WebAPIClient()
+ api = WebApiClient()
api.enable_async(error_handler=api_error_handler,
success_handler=api_success_handler)
diff --git a/test/test_send_fake_sound_hit.py b/test/test_send_fake_sound_hit.py
index 9660c45..3cc3e50 100755
--- a/test/test_send_fake_sound_hit.py
+++ b/test/test_send_fake_sound_hit.py
@@ -1,14 +1,8 @@
#!/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__)), '..')
- )
-])
+import __py_include
from argparse import ArgumentParser
-from src.home.util import send_datagram, stringify, parse_addr
+from homekit.util import send_datagram, stringify, Addr
if __name__ == '__main__':
@@ -22,4 +16,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_sensors_plot.py b/test/test_sensors_plot.py
deleted file mode 100755
index e69de29..0000000
--- a/test/test_sensors_plot.py
+++ /dev/null
diff --git a/test/test_sound_node_client.py b/test/test_sound_node_client.py
index 16feb78..c3748ca 100755
--- a/test/test_sound_node_client.py
+++ b/test/test_sound_node_client.py
@@ -1,11 +1,8 @@
#!/usr/bin/env python3
-import sys, os.path
-sys.path.extend([
- os.path.realpath(os.path.join(os.path.dirname(os.path.join(__file__)), '..')),
-])
+import __py_include
-from src.home.api.errors import ApiResponseError
-from src.home.media import SoundNodeClient
+from homekit.api.errors import ApiResponseError
+from homekit.media import SoundNodeClient
if __name__ == '__main__':
diff --git a/test/test_sound_server_api.py b/test/test_sound_server_api.py
index e68c6f8..11cd422 100755
--- a/test/test_sound_server_api.py
+++ b/test/test_sound_server_api.py
@@ -1,17 +1,11 @@
#!/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__)), '..')
- )
-])
+import __py_include
import threading
from time import sleep
-from src.home.config import config
-from src.home.api import WebAPIClient
-from src.home.api.types import SoundSensorLocation
+from homekit.config import config
+from homekit.api import WebApiClient
+from homekit.api.types import SoundSensorLocation
from typing import List, Tuple
interrupted = False
@@ -56,10 +50,10 @@ def hits_sender():
if __name__ == '__main__':
- config.load('test_api')
+ config.load_app('test_api')
hc = HitCounter()
- api = WebAPIClient()
+ api = WebApiClient()
hc.add('spb1', 1)
# hc.add('big_house', 123)
diff --git a/test/test_stopwatch.py b/test/test_stopwatch.py
index 6ff2c0e..1da0fe7 100755
--- a/test/test_stopwatch.py
+++ b/test/test_stopwatch.py
@@ -1,4 +1,5 @@
-from home.util import Stopwatch, StopwatchError
+import __py_include
+from homekit.util import Stopwatch, StopwatchError
from time import sleep
diff --git a/test/test_telegram_aio_send_photo.py b/test/test_telegram_aio_send_photo.py
index 705e534..019fa92 100644
--- a/test/test_telegram_aio_send_photo.py
+++ b/test/test_telegram_aio_send_photo.py
@@ -1,16 +1,9 @@
#!/usr/bin/env python3
+import __py_include
import asyncio
-import sys
-import os.path
-sys.path.extend([
- os.path.realpath(
- os.path.join(os.path.dirname(os.path.join(__file__)), '..')
- )
-])
+import homekit.telegram.aio as telegram
-import src.home.telegram.aio as telegram
-
-from src.home.config import config
+from homekit.config import config
async def main():
@@ -20,7 +13,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())