#2041: ntp_server test fixes.

This commit is contained in:
Nick Todd
2023-11-20 18:08:55 +00:00
parent b0b37f9da5
commit f7215847d4
3 changed files with 21 additions and 12 deletions

View File

@@ -34,11 +34,11 @@ class NTPPacket(DataPacket):
"NTP Request packet sent by NTP Client."
ntp_reply: Optional[NTPReply] = None
def generate_reply(self, time: datetime) -> NTPPacket:
def generate_reply(self, ntp_server_time: datetime) -> NTPPacket:
"""Generate a NTPPacket containing the time in a NTPReply object.
:param time: datetime object representing the time from the NTP server.
:return: A new NTPPacket object.
"""
self.ntp_reply = NTPReply(time)
self.ntp_reply = NTPReply(ntp_datetime=ntp_server_time)
return self

View File

@@ -50,7 +50,8 @@ class NTPServer(Service):
session_id: Optional[str] = None,
**kwargs,
) -> bool:
"""Receives a request from NTPClient.
"""
Receives a request from NTPClient.
Check that request has a valid IP address.
@@ -75,5 +76,6 @@ class NTPServer(Service):
f"with current time: {time}"
)
# send reply
self.send(payload, session_id)
return True
if self.send(payload, session_id):
return True
return False