Add HTTP unittest with NarodMon format

This commit is contained in:
DarkCat09 2024-05-31 16:22:25 +04:00
parent c0d502369a
commit b0b6d221a3
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

20
main.py
View file

@ -1,5 +1,5 @@
import socket import socket
import urllib from urllib.request import urlopen, Request
from functools import partial from functools import partial
from unittest import TestCase from unittest import TestCase
@ -38,3 +38,21 @@ class TestTCP(TestCase):
def _wait_for_ok(self) -> None: def _wait_for_ok(self) -> None:
data = self.sock.recv(1024) data = self.sock.recv(1024)
self.assertEqual(data, b'OK') 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)