Update tests (see "refactor" commit)

This commit is contained in:
DarkCat09 2024-05-31 17:49:44 +04:00
parent ef41123264
commit 3668a917a7
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

26
main.py
View file

@ -1,26 +1,15 @@
import socket
from urllib.request import urlopen, Request
from functools import partial
from unittest import TestCase
import models
import fixtures
from fixtures import device
TCP_ADDR = ('127.0.0.1', 8283)
UDP_ADDR = ('127.0.0.1', 8283)
HTTP_URL = 'http://127.0.0.1:8080'
nm_req = partial(
models.create_nm_req,
fixtures.device_mac,
fixtures.device_name,
fixtures.sensors,
)
json_req = None # TODO
class TestTCP(TestCase):
@ -29,7 +18,7 @@ class TestTCP(TestCase):
self.sock.connect(TCP_ADDR)
def test_nm(self) -> None:
self.sock.sendall(nm_req())
self.sock.sendall(device.nm_req_data().encode())
self._wait_for_ok()
def test_json(self) -> None:
@ -42,13 +31,10 @@ class TestTCP(TestCase):
class TestHTTP(TestCase):
def test_nm(self) -> None:
req = Request(
url=(HTTP_URL + '/get'),
data=nm_req(),
method='GET',
)
self._send_and_check(req)
def test_get(self) -> None:
self._send_and_check(Request(
HTTP_URL + '/get?' + device.http_req_data(),
))
def test_json(self) -> None:
raise NotImplemented