From c0d502369a3aa14839a2594188282373f2edd138 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 31 May 2024 16:20:25 +0400 Subject: [PATCH] Return bytes in models.create_* --- main.py | 5 ++--- models.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index d0f0fd2..425a77a 100644 --- a/main.py +++ b/main.py @@ -29,12 +29,11 @@ class TestTCP(TestCase): self.sock.connect(TCP_ADDR) def test_nm(self) -> None: - self.sock.sendall(nm_req().encode('utf-8')) + self.sock.sendall(nm_req()) self._wait_for_ok() def test_json(self) -> None: - self.sock.sendall(b'') # TODO - self._wait_for_ok() + raise NotImplemented def _wait_for_ok(self) -> None: data = self.sock.recv(1024) diff --git a/models.py b/models.py index 6639004..31eb000 100644 --- a/models.py +++ b/models.py @@ -13,7 +13,7 @@ class SensorData: def create_nm_req( dev_mac: str, dev_name: str | None = None, - sensors: Iterable[SensorData] = ()) -> str: + sensors: Iterable[SensorData] = ()) -> bytes: '''Generate a NarodMon format (#mac#value) request''' res = '#' + dev_mac @@ -29,4 +29,4 @@ def create_nm_req( res += '#' + s.name res += '\n' - return res + return res.encode('utf-8')