Removed a transaction.commit() that was unnecessary.

This commit is contained in:
Michael Woods
2025-12-25 15:31:28 -05:00
parent 60165d658c
commit 00cf6ab674
3 changed files with 109 additions and 0 deletions

51
examples/misc/test.py Normal file
View File

@@ -0,0 +1,51 @@
from packetserver.common import DummyPacketServerConnection, Request, Response, Message
from packetserver.server import TestServer
from packetserver.server.objects import Object
from packetserver.server.messages import Message as Mail
from packetserver.server.messages import Attachment
import time
import logging
import json
logging.basicConfig(level=logging.DEBUG)
server_callsign = "KQ4PEC"
client_callsign = 'KQ4PEC-7'
#client_callsign = "TEST1"
ts = TestServer(server_callsign, zeo=True)
ts.start()
time.sleep(1)
print("creating connection")
conn = DummyPacketServerConnection(client_callsign, server_callsign, incoming=True)
print(conn.remote_callsign)
print(conn.call_to)
print(conn.call_from)
conn.connected()
req = Request.blank()
req.set_var('fetch_attachments', 1)
req.path = "message"
#req.method=Request.Method.POST
#attach = [Attachment("test.txt", "Hello sir, I hope that this message finds you well. The other day..")]
#req.payload = Mail("Hi there from a test user!", "KQ4PEC", attachments=attach).to_dict()
#req.payload = Object(name="test.txt", data="hello there").to_dict()
print("sending request")
conn.data_received(0, bytearray(req.pack()))
#ts.send_test_data(conn, bytearray(req.pack()))
print("Waiting on response.")
time.sleep(.5)
ts.stop()
msg = conn.sent_data.unpack()
#print(f"msg: {msg}")
response = Response(Message.partial_unpack(msg))
#print(type(response.payload))
#print(f"Response: {response}: {response.payload}")
print(json.dumps(response.payload, indent=4))