From 3668a917a7f738839fe5c87cb17f154f2ad5e0eb Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 31 May 2024 17:49:44 +0400 Subject: [PATCH] Update tests (see "refactor" commit) --- main.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/main.py b/main.py index 17e22f2..8e6feb2 100644 --- a/main.py +++ b/main.py @@ -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