summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2022-04-11 04:57:48 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2022-04-11 04:57:48 +0200
commite83f1e89da0a8fb5527435a61743b9f0769caa7c (patch)
tree76c4d06874e6981b737406e80515acc8236e94c9 /test.py
parent6108b3a1c10d66f8c446ee54acdbe52efcfdf4e8 (diff)
server.c: Reply to USER messages from client
Diffstat (limited to 'test.py')
-rw-r--r--test.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/test.py b/test.py
index e1e3028..9f6421e 100644
--- a/test.py
+++ b/test.py
@@ -4,10 +4,14 @@ import threading
import time
import unittest
+
libpapo = ctypes.CDLL('./libpapo.so')
+unittest.util._MAX_LENGTH=2000
+
class PapoServerTest(unittest.TestCase):
+
@classmethod
def setUpClass(cls):
server = papo_server();
@@ -15,23 +19,27 @@ class PapoServerTest(unittest.TestCase):
thread.start()
time.sleep(2)
+
@classmethod
def tearDownClass(cls):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('localhost', 6667))
s.sendall(b'exit')
+
@classmethod
def run_papo_server(cls, server):
libpapo.server_init(ctypes.byref(server), 6667)
libpapo.server_run(ctypes.byref(server))
+
def test_server_run(self):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('localhost', 6667))
- s.sendall(b'A msg from client')
+ s.sendall(b'USER username 0 * :User Name\r\n')
data = s.recv(1024)
- self.assertIn(b':A msg from client', data)
+ self.assertIn(b'001 username :Welcome!\r\n', data)
+
class epoll_data(ctypes.Union):
_fields_ = [('ptr', ctypes.c_void_p),
@@ -39,6 +47,7 @@ class epoll_data(ctypes.Union):
('u32', ctypes.c_uint),
('u64', ctypes.c_ulong)]
+
class epoll_event(ctypes.Structure):
_fields_ = [('events', ctypes.c_uint),
('epoll_data_t', epoll_data)]