mirror of
https://github.com/seregonwar/zftpd.git
synced 2026-10-23 04:02:21 -05:00
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.
35 lines
906 B
Python
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__
|