tests.server package#
Submodules#
tests.server.config module#
Server configuration.
tests.server.errors module#
Error messages.
tests.server.listens module#
- class tests.server.listens.Listens[source]#
Bases:
objectA class that manages listeners and notifies them of changes in status.
- Attributes:
_listeners (list[callable]): A list of callback functions to be executed when a change in status occurs. _notify_listeners_task (Task): An asyncio task that executes the coroutines of the listeners concurrently. status (RawListens): An instance of the RawListens class representing the current status. _count (int): A counter to keep track of the number of listeners.
- Methods:
__init__(): Initializes the Listens object. _notify_listeners(new_status): Notifies all listeners of a change in status. add_listener(callback): Adds a new listener to the list of listeners. stop_listening(): Removes all listeners from the list.
- add_listener(callback: callable) None[source]#
Adds a new listener to the list of listeners.
- Args:
callback: The callback function to be added as a listener.
- status: RawListens#
A descriptor class for accessing and updating the status of a Listens object.
This class provides the __get__ and __set__ methods to get and set the status of a Listens object. When the status is updated, it notifies the listeners asynchronously.
- Attributes:
None
- Methods:
- __get__(self, obj: Listens, objtype=None) -> Any:
Get the status of the Listens object.
- __set__(self, obj: Listens, value) -> None:
Set the status of the Listens object and notify the listeners.
- class tests.server.listens.RawListens[source]#
Bases:
objectA descriptor class for accessing and updating the status of a Listens object.
This class provides the __get__ and __set__ methods to get and set the status of a Listens object. When the status is updated, it notifies the listeners asynchronously.
- Attributes:
None
- Methods:
- __get__(self, obj: Listens, objtype=None) -> Any:
Get the status of the Listens object.
- __set__(self, obj: Listens, value) -> None:
Set the status of the Listens object and notify the listeners.
tests.server.logger module#
tests.server.manager module#
The middleman between Plover and the server.
- class tests.server.manager.EngineServerManager[source]#
Bases:
objectManages a server that exposes the Plover engine.
- add_listener(listener: callable) None[source]#
Adds a listener to the server.
- Args:
listener (callable): The listener function to be added.
- get_server_status() ServerStatus[source]#
Gets the status of the server.
- Returns:
The status of the server.
tests.server.server module#
Core engine server definitions.
- class tests.server.server.EngineServer(host: str, port: str)[source]#
Bases:
objectA server example.
This class represents a server that can be started and stopped. It provides methods to queue messages for broadcasting and register callbacks to handle received messages.
- Attributes:
listened: An instance of the Listens class representing the listeners for the server. data: An instance of the Listens class representing the data received by the server.
- queue_message(data: dict) Future[source]#
Queues a message for the server to broadcast.
Assumes it is called from a thread different from the event loop.
- Args:
data: The data in JSON format to broadcast.
- queue_stop() None[source]#
Queues the server to stop.
Assumes it is called from a thread different from the event loop.