Files
zftpd/ffi/python/tests/test_ffi.py
T
Seregon d04082deb5 Change default HTTP port to 8888
Switch the default HTTP port from 8080 to 8888 across the codebase. Updated include/http_config.h macro and example in include/http_server.h, adjusted tests and examples in ffi Java/Python/Rust test files, and updated tests/main.c to create the server on and print the new port. Ensures tests and docs use the same default port.
2026-02-28 15:38:57 +01:00

35 lines
906 B
Python

import pytest
from zftpd.core import PalAlloc, EventLoop, FtpServer, HttpServer
def test_pal_alloc():
# Initialize allocator
assert PalAlloc.init_default() is True
# Allocate memory
ptr = PalAlloc.malloc(1024)
assert ptr is not None
# Check approximate free space
free_approx = PalAlloc.get_arena_free_approx()
assert free_approx > 0
# Free memory
PalAlloc.free(ptr)
def test_ftp_server():
server = FtpServer("127.0.0.1", 2121, "/tmp")
server.start()
assert server.is_running() is True
assert server.active_sessions() == 0
server.stop()
assert server.is_running() is False
server.close()
def test_http_server():
# Loop and Server both implement Context Manager protocol
with EventLoop() as loop:
with HttpServer(loop, 8888) as http:
pass # Creating it implies it works; will auto-close on __exit__