From b0b6d221a38b52f5b98ccaca9505cd6710cdcead Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 31 May 2024 16:22:25 +0400 Subject: [PATCH] Add HTTP unittest with NarodMon format --- main.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 425a77a..17e22f2 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ import socket -import urllib +from urllib.request import urlopen, Request from functools import partial from unittest import TestCase @@ -38,3 +38,21 @@ class TestTCP(TestCase): def _wait_for_ok(self) -> None: data = self.sock.recv(1024) self.assertEqual(data, b'OK') + + +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_json(self) -> None: + raise NotImplemented + + def _send_and_check(self, req: Request) -> None: + with urlopen(req) as resp: + self.assertEqual(resp.status, 200)