diff --git a/docs/api/basic.rst b/docs/api/basic.rst index 554e4ff7..7fbe47c0 100644 --- a/docs/api/basic.rst +++ b/docs/api/basic.rst @@ -34,27 +34,27 @@ These are the classes that you get back after making a request. For Java Server *************** -.. module:: mcstatus.status_response +.. module:: mcstatus.responses -.. autoclass:: mcstatus.status_response.JavaStatusResponse() +.. autoclass:: mcstatus.responses.JavaStatusResponse() :members: :undoc-members: :inherited-members: :exclude-members: build -.. autoclass:: mcstatus.status_response.JavaStatusPlayers() +.. autoclass:: mcstatus.responses.JavaStatusPlayers() :members: :undoc-members: :inherited-members: :exclude-members: build -.. autoclass:: mcstatus.status_response.JavaStatusPlayer() +.. autoclass:: mcstatus.responses.JavaStatusPlayer() :members: :undoc-members: :inherited-members: :exclude-members: build -.. autoclass:: mcstatus.status_response.JavaStatusVersion() +.. autoclass:: mcstatus.responses.JavaStatusVersion() :members: :undoc-members: :inherited-members: @@ -144,22 +144,22 @@ For Java Server For Bedrock Servers ******************* -.. module:: mcstatus.status_response +.. module:: mcstatus.responses :noindex: -.. autoclass:: mcstatus.status_response.BedrockStatusResponse() +.. autoclass:: mcstatus.responses.BedrockStatusResponse() :members: :undoc-members: :inherited-members: :exclude-members: build -.. autoclass:: mcstatus.status_response.BedrockStatusPlayers() +.. autoclass:: mcstatus.responses.BedrockStatusPlayers() :members: :undoc-members: :inherited-members: :exclude-members: build -.. autoclass:: mcstatus.status_response.BedrockStatusVersion() +.. autoclass:: mcstatus.responses.BedrockStatusVersion() :members: :undoc-members: :inherited-members: diff --git a/docs/api/internal.rst b/docs/api/internal.rst index cbb29d62..33563390 100644 --- a/docs/api/internal.rst +++ b/docs/api/internal.rst @@ -49,17 +49,17 @@ versions. They are only documented here for linkable reference to them. :undoc-members: :show-inheritance: -.. autoclass:: mcstatus.status_response.BaseStatusResponse +.. autoclass:: mcstatus.responses.BaseStatusResponse :members: :undoc-members: :show-inheritance: -.. autoclass:: mcstatus.status_response.BaseStatusPlayers +.. autoclass:: mcstatus.responses.BaseStatusPlayers :members: :undoc-members: :show-inheritance: -.. autoclass:: mcstatus.status_response.BaseStatusVersion +.. autoclass:: mcstatus.responses.BaseStatusVersion :members: :undoc-members: :show-inheritance: diff --git a/docs/examples/code/ping_as_java_and_bedrock_in_one_time.py b/docs/examples/code/ping_as_java_and_bedrock_in_one_time.py index 1e09d654..16481b14 100644 --- a/docs/examples/code/ping_as_java_and_bedrock_in_one_time.py +++ b/docs/examples/code/ping_as_java_and_bedrock_in_one_time.py @@ -1,7 +1,7 @@ import asyncio from mcstatus import BedrockServer, JavaServer -from mcstatus.status_response import BedrockStatusResponse, JavaStatusResponse +from mcstatus.responses import BedrockStatusResponse, JavaStatusResponse async def status(host: str) -> JavaStatusResponse | BedrockStatusResponse: diff --git a/docs/examples/ping_as_java_and_bedrock_in_one_time.rst b/docs/examples/ping_as_java_and_bedrock_in_one_time.rst index 3c512165..c18fd8ca 100644 --- a/docs/examples/ping_as_java_and_bedrock_in_one_time.rst +++ b/docs/examples/ping_as_java_and_bedrock_in_one_time.rst @@ -5,8 +5,8 @@ You can easily ping a server as a Java server and as a Bedrock server in one tim .. literalinclude:: code/ping_as_java_and_bedrock_in_one_time.py -As you can see in the code, ``status`` function returns :class:`~mcstatus.status_response.JavaStatusResponse` -or :class:`~mcstatus.status_response.BedrockStatusResponse` object. You can use +As you can see in the code, ``status`` function returns :class:`~mcstatus.responses.JavaStatusResponse` +or :class:`~mcstatus.responses.BedrockStatusResponse` object. You can use :func:`isinstance` checks to access attributes that are only in one of the objects. diff --git a/docs/pages/faq.rst b/docs/pages/faq.rst index 213815b1..70980937 100644 --- a/docs/pages/faq.rst +++ b/docs/pages/faq.rst @@ -57,7 +57,7 @@ How to get server image? On Bedrock, only official servers have a server image. There is no way to get or set an icon to a custom server. For Java servers, you can use -:attr:`status.icon ` +:attr:`status.icon ` attribute. It will return `Base64 `_ encoded PNG image. If you wish to save this image into a file, this is how: diff --git a/mcstatus/bedrock_status.py b/mcstatus/bedrock_status.py index f98156d0..1e5ce67d 100644 --- a/mcstatus/bedrock_status.py +++ b/mcstatus/bedrock_status.py @@ -8,7 +8,7 @@ import asyncio_dgram from mcstatus.address import Address -from mcstatus.status_response import BedrockStatusResponse +from mcstatus.responses import BedrockStatusResponse class BedrockServerStatus: diff --git a/mcstatus/forge_data.py b/mcstatus/forge_data.py index 99412d78..680863c6 100644 --- a/mcstatus/forge_data.py +++ b/mcstatus/forge_data.py @@ -56,7 +56,7 @@ class RawForgeData(TypedDict, total=False): RawForgeData = dict -@dataclass +@dataclass(frozen=True) class ForgeDataChannel: name: str """Channel name and ID (for example ``fml:handshake``).""" @@ -95,7 +95,7 @@ def decode(cls, buffer: Connection, mod_id: str | None = None) -> Self: ) -@dataclass +@dataclass(frozen=True) class ForgeDataMod: name: str marker: str @@ -192,7 +192,7 @@ def read_optimized_buffer(self) -> Connection: return buffer -@dataclass +@dataclass(frozen=True) class ForgeData: fml_network_version: int """Forge Mod Loader network version.""" diff --git a/mcstatus/motd/__init__.py b/mcstatus/motd/__init__.py index d9320363..a36064cd 100644 --- a/mcstatus/motd/__init__.py +++ b/mcstatus/motd/__init__.py @@ -11,7 +11,7 @@ if t.TYPE_CHECKING: from typing_extensions import Self - from mcstatus.status_response import RawJavaResponseMotd, RawJavaResponseMotdWhenDict # circular import + from mcstatus.responses import RawJavaResponseMotd, RawJavaResponseMotdWhenDict # circular import else: RawJavaResponseMotdWhenDict = dict diff --git a/mcstatus/pinger.py b/mcstatus/pinger.py index 17945eaa..83464b42 100644 --- a/mcstatus/pinger.py +++ b/mcstatus/pinger.py @@ -6,7 +6,7 @@ from mcstatus.address import Address from mcstatus.protocol.connection import Connection, TCPAsyncSocketConnection, TCPSocketConnection -from mcstatus.status_response import JavaStatusResponse +from mcstatus.responses import JavaStatusResponse class ServerPinger: diff --git a/mcstatus/responses.py b/mcstatus/responses.py new file mode 100644 index 00000000..6786fafe --- /dev/null +++ b/mcstatus/responses.py @@ -0,0 +1,342 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from dataclasses import dataclass +from typing import Any, TYPE_CHECKING + +from mcstatus.forge_data import ForgeData, RawForgeData +from mcstatus.motd import Motd + +if TYPE_CHECKING: + from typing_extensions import NotRequired, Self, TypeAlias, TypedDict + + class RawJavaResponsePlayer(TypedDict): + name: str + id: str + + class RawJavaResponsePlayers(TypedDict): + online: int + max: int + sample: NotRequired[list[RawJavaResponsePlayer]] + + class RawJavaResponseVersion(TypedDict): + name: str + protocol: int + + class RawJavaResponseMotdWhenDict(TypedDict, total=False): + text: str # only present if `translate` is set + translate: str # same to the above field + extra: list[RawJavaResponseMotdWhenDict | str] + + color: str + bold: bool + strikethrough: bool + italic: bool + underlined: bool + obfuscated: bool + + RawJavaResponseMotd: TypeAlias = "RawJavaResponseMotdWhenDict | list[RawJavaResponseMotdWhenDict | str] | str" + + class RawJavaResponse(TypedDict): + description: RawJavaResponseMotd + players: RawJavaResponsePlayers + version: RawJavaResponseVersion + favicon: NotRequired[str] + forgeData: NotRequired[RawForgeData] + modinfo: NotRequired[RawForgeData] + enforcesSecureChat: NotRequired[bool] + +else: + RawJavaResponsePlayer = dict + RawJavaResponsePlayers = dict + RawJavaResponseVersion = dict + RawJavaResponseMotdWhenDict = dict + RawJavaResponse = dict + +from mcstatus.utils import deprecated + +__all__ = [ + "BaseStatusPlayers", + "BaseStatusResponse", + "BaseStatusVersion", + "BedrockStatusPlayers", + "BedrockStatusResponse", + "BedrockStatusVersion", + "JavaStatusPlayer", + "JavaStatusPlayers", + "JavaStatusResponse", + "JavaStatusVersion", +] + + +@dataclass(frozen=True) +class BaseStatusResponse(ABC): + """Class for storing shared data from a status response.""" + + players: BaseStatusPlayers + """The players information.""" + version: BaseStatusVersion + """The version information.""" + motd: Motd + """Message Of The Day. Also known as description. + + .. seealso:: :doc:`/api/motd_parsing`. + """ + latency: float + """Latency between a server and the client (you). In milliseconds.""" + + @property + def description(self) -> str: + """Alias to the :meth:`mcstatus.motd.Motd.to_minecraft` method.""" + return self.motd.to_minecraft() + + @classmethod + @abstractmethod + def build(cls, *args, **kwargs) -> Self: + """Build BaseStatusResponse and check is it valid. + + :param args: Arguments in specific realisation. + :param kwargs: Keyword arguments in specific realisation. + :return: :class:`BaseStatusResponse` object. + """ + raise NotImplementedError("You can't use abstract methods.") + + +@dataclass(frozen=True) +class JavaStatusResponse(BaseStatusResponse): + """The response object for :meth:`JavaServer.status() `.""" + + raw: RawJavaResponse + """Raw response from the server. + + This is :class:`~typing.TypedDict` actually, please see sources to find what is here. + """ + players: JavaStatusPlayers + version: JavaStatusVersion + enforces_secure_chat: bool | None + """Whether the server enforces secure chat (every message is signed up with a key). + + .. seealso:: + `Signed Chat explanation `_, + `22w17a changelog, where this was added `_. + + .. versionadded:: 11.1.0 + """ + icon: str | None + """The icon of the server. In `Base64 `_ encoded PNG image format. + + .. seealso:: :ref:`pages/faq:how to get server image?` + """ + forge_data: ForgeData | None + """Forge mod data (mod list, channels, etc). Only present if this is a forge (modded) server.""" + + @classmethod + def build(cls, raw: RawJavaResponse, latency: float = 0) -> Self: + """Build JavaStatusResponse and check is it valid. + + :param raw: Raw response :class:`dict`. + :param latency: Time that server took to response (in milliseconds). + :raise ValueError: If the required keys (``players``, ``version``, ``description``) are not present. + :raise TypeError: + If the required keys (``players`` - :class:`dict`, ``version`` - :class:`dict`, + ``description`` - :class:`str`) are not of the expected type. + :return: :class:`JavaStatusResponse` object. + """ + forge_data: ForgeData | None = None + if "forgeData" in raw or "modinfo" in raw: + raw_forge = raw.get("forgeData") or raw.get("modinfo") + assert raw_forge is not None + forge_data = ForgeData.build(raw_forge) + + return cls( + raw=raw, + players=JavaStatusPlayers.build(raw["players"]), + version=JavaStatusVersion.build(raw["version"]), + motd=Motd.parse(raw["description"], bedrock=False), + enforces_secure_chat=raw.get("enforcesSecureChat"), + icon=raw.get("favicon"), + latency=latency, + forge_data=forge_data, + ) + + +@dataclass(frozen=True) +class BedrockStatusResponse(BaseStatusResponse): + """The response object for :meth:`BedrockServer.status() `.""" + + players: BedrockStatusPlayers + version: BedrockStatusVersion + map_name: str | None + """The name of the map.""" + gamemode: str | None + """The name of the gamemode on the server.""" + + @classmethod + def build(cls, decoded_data: list[Any], latency: float) -> Self: + """Build BaseStatusResponse and check is it valid. + + :param decoded_data: Raw decoded response object. + :param latency: Latency of the request. + :return: :class:`BedrockStatusResponse` object. + """ + + try: + map_name = decoded_data[7] + except IndexError: + map_name = None + try: + gamemode = decoded_data[8] + except IndexError: + gamemode = None + + return cls( + players=BedrockStatusPlayers( + online=int(decoded_data[4]), + max=int(decoded_data[5]), + ), + version=BedrockStatusVersion( + name=decoded_data[3], + protocol=int(decoded_data[2]), + brand=decoded_data[0], + ), + motd=Motd.parse(decoded_data[1], bedrock=True), + latency=latency, + map_name=map_name, + gamemode=gamemode, + ) + + +@dataclass(frozen=True) +class BaseStatusPlayers(ABC): + """Class for storing information about players on the server.""" + + online: int + """Current number of online players.""" + max: int + """The maximum allowed number of players (aka server slots).""" + + +@dataclass(frozen=True) +class JavaStatusPlayers(BaseStatusPlayers): + """Class for storing information about players on the server.""" + + sample: list[JavaStatusPlayer] | None + """List of players, who are online. If server didn't provide this, it will be :obj:`None`. + + Actually, this is what appears when you hover over the slot count on the multiplayer screen. + + .. note:: + It's often empty or even contains some advertisement, because the specific server implementations or plugins can + disable providing this information or even change it to something custom. + + There is nothing that ``mcstatus`` can to do here if the player sample was modified/disabled like this. + """ + + @classmethod + def build(cls, raw: RawJavaResponsePlayers) -> Self: + """Build :class:`JavaStatusPlayers` from raw response :class:`dict`. + + :param raw: Raw response :class:`dict`. + :raise ValueError: If the required keys (``online``, ``max``) are not present. + :raise TypeError: + If the required keys (``online`` - :class:`int`, ``max`` - :class:`int`, + ``sample`` - :class:`list`) are not of the expected type. + :return: :class:`JavaStatusPlayers` object. + """ + sample = None + if "sample" in raw: + sample = [JavaStatusPlayer.build(player) for player in raw["sample"]] + return cls( + online=raw["online"], + max=raw["max"], + sample=sample, + ) + + +@dataclass(frozen=True) +class BedrockStatusPlayers(BaseStatusPlayers): + """Class for storing information about players on the server.""" + + +@dataclass(frozen=True) +class JavaStatusPlayer: + """Class with information about a single player.""" + + name: str + """Name of the player.""" + id: str + """ID of the player (in `UUID `_ format).""" + + @property + def uuid(self) -> str: + """Alias to :attr:`.id` field.""" + return self.id + + @classmethod + def build(cls, raw: RawJavaResponsePlayer) -> Self: + """Build :class:`JavaStatusPlayer` from raw response :class:`dict`. + + :param raw: Raw response :class:`dict`. + :raise ValueError: If the required keys (``name``, ``id``) are not present. + :raise TypeError: If the required keys (``name`` - :class:`str`, ``id`` - :class:`str`) + are not of the expected type. + :return: :class:`JavaStatusPlayer` object. + """ + return cls(name=raw["name"], id=raw["id"]) + + +@dataclass(frozen=True) +class BaseStatusVersion(ABC): + """A class for storing version information.""" + + name: str + """The version name, like ``1.19.3``. + + See `Minecraft wiki `__ + for complete list. + """ + protocol: int + """The protocol version, like ``761``. + + See `Minecraft wiki `__. + """ + + +@dataclass(frozen=True) +class JavaStatusVersion(BaseStatusVersion): + """A class for storing version information.""" + + @classmethod + def build(cls, raw: RawJavaResponseVersion) -> Self: + """Build :class:`JavaStatusVersion` from raw response dict. + + :param raw: Raw response :class:`dict`. + :raise ValueError: If the required keys (``name``, ``protocol``) are not present. + :raise TypeError: If the required keys (``name`` - :class:`str`, ``protocol`` - :class:`int`) + are not of the expected type. + :return: :class:`JavaStatusVersion` object. + """ + return cls(name=raw["name"], protocol=raw["protocol"]) + + +@dataclass(frozen=True) +class BedrockStatusVersion(BaseStatusVersion): + """A class for storing version information.""" + + name: str + """The version name, like ``1.19.60``. + + See `Minecraft wiki `__ + for complete list. + """ + brand: str + """``MCPE`` or ``MCEE`` for Education Edition.""" + + @property + @deprecated(replacement="name", date="2023-12") + def version(self) -> str: + """ + .. deprecated:: 11.0.0 + Will be removed 2023-12, use :attr:`.name` instead. + """ + return self.name diff --git a/mcstatus/server.py b/mcstatus/server.py index 49759dc2..cbc77b26 100644 --- a/mcstatus/server.py +++ b/mcstatus/server.py @@ -13,7 +13,7 @@ UDPSocketConnection, ) from mcstatus.querier import AsyncServerQuerier, QueryResponse, ServerQuerier -from mcstatus.status_response import BedrockStatusResponse, JavaStatusResponse +from mcstatus.responses import BedrockStatusResponse, JavaStatusResponse from mcstatus.utils import TRIES_USED_BY_US, retry if TYPE_CHECKING: @@ -120,7 +120,7 @@ def status(self, **kwargs) -> JavaStatusResponse: """Checks the status of a Minecraft Java Edition server via the status protocol. :param kwargs: Passed to a :class:`~mcstatus.pinger.ServerPinger` instance. - :return: Status information in a :class:`~mcstatus.status_response.JavaStatusResponse` instance. + :return: Status information in a :class:`~mcstatus.responses.JavaStatusResponse` instance. """ with TCPSocketConnection(self.address, self.timeout) as connection: @@ -137,7 +137,7 @@ async def async_status(self, **kwargs) -> JavaStatusResponse: """Asynchronously checks the status of a Minecraft Java Edition server via the status protocol. :param kwargs: Passed to a :class:`~mcstatus.pinger.AsyncServerPinger` instance. - :return: Status information in a :class:`~mcstatus.status_response.JavaStatusResponse` instance. + :return: Status information in a :class:`~mcstatus.responses.JavaStatusResponse` instance. """ async with TCPAsyncSocketConnection(self.address, self.timeout) as connection: @@ -193,7 +193,7 @@ def status(self, **kwargs) -> BedrockStatusResponse: """Checks the status of a Minecraft Bedrock Edition server. :param kwargs: Passed to a :class:`~mcstatus.bedrock_status.BedrockServerStatus` instance. - :return: Status information in a :class:`~mcstatus.status_response.BedrockStatusResponse` instance. + :return: Status information in a :class:`~mcstatus.responses.BedrockStatusResponse` instance. """ return BedrockServerStatus(self.address, self.timeout, **kwargs).read_status() @@ -202,6 +202,6 @@ async def async_status(self, **kwargs) -> BedrockStatusResponse: """Asynchronously checks the status of a Minecraft Bedrock Edition server. :param kwargs: Passed to a :class:`~mcstatus.bedrock_status.BedrockServerStatus` instance. - :return: Status information in a :class:`~mcstatus.status_response.BedrockStatusResponse` instance. + :return: Status information in a :class:`~mcstatus.responses.BedrockStatusResponse` instance. """ return await BedrockServerStatus(self.address, self.timeout, **kwargs).read_status_async() diff --git a/mcstatus/status_response.py b/mcstatus/status_response.py index 85d44422..1d02f400 100644 --- a/mcstatus/status_response.py +++ b/mcstatus/status_response.py @@ -1,59 +1,17 @@ -from __future__ import annotations - -from abc import ABC, abstractmethod -from dataclasses import dataclass -from typing import Any, TYPE_CHECKING - -from mcstatus.forge_data import ForgeData, RawForgeData -from mcstatus.motd import Motd - -if TYPE_CHECKING: - from typing_extensions import NotRequired, Self, TypeAlias, TypedDict - - class RawJavaResponsePlayer(TypedDict): - name: str - id: str - - class RawJavaResponsePlayers(TypedDict): - online: int - max: int - sample: NotRequired[list[RawJavaResponsePlayer]] - - class RawJavaResponseVersion(TypedDict): - name: str - protocol: int - - class RawJavaResponseMotdWhenDict(TypedDict, total=False): - text: str # only present if `translate` is set - translate: str # same to the above field - extra: list[RawJavaResponseMotdWhenDict | str] - - color: str - bold: bool - strikethrough: bool - italic: bool - underlined: bool - obfuscated: bool - - RawJavaResponseMotd: TypeAlias = "RawJavaResponseMotdWhenDict | list[RawJavaResponseMotdWhenDict | str] | str" - - class RawJavaResponse(TypedDict): - description: RawJavaResponseMotd - players: RawJavaResponsePlayers - version: RawJavaResponseVersion - favicon: NotRequired[str] - forgeData: NotRequired[RawForgeData] - modinfo: NotRequired[RawForgeData] - enforcesSecureChat: NotRequired[bool] - -else: - RawJavaResponsePlayer = dict - RawJavaResponsePlayers = dict - RawJavaResponseVersion = dict - RawJavaResponseMotdWhenDict = dict - RawJavaResponse = dict - - +from mcstatus.responses import ( + BaseStatusPlayers, + BaseStatusResponse, + BaseStatusVersion, + BedrockStatusPlayers, + BedrockStatusResponse, + BedrockStatusVersion, + JavaStatusPlayer, + JavaStatusPlayers, + JavaStatusResponse, + JavaStatusVersion, +) + +# __all__ is frozen on the moment of deprecation __all__ = [ "BaseStatusPlayers", "BaseStatusResponse", @@ -68,265 +26,10 @@ class RawJavaResponse(TypedDict): ] -@dataclass(frozen=True) -class BaseStatusResponse(ABC): - """Class for storing shared data from a status response.""" - - players: BaseStatusPlayers - """The players information.""" - version: BaseStatusVersion - """The version information.""" - motd: Motd - """Message Of The Day. Also known as description. - - .. seealso:: :doc:`/api/motd_parsing`. - """ - latency: float - """Latency between a server and the client (you). In milliseconds.""" - - @property - def description(self) -> str: - """Alias to the :meth:`mcstatus.motd.Motd.to_minecraft` method.""" - return self.motd.to_minecraft() - - @classmethod - @abstractmethod - def build(cls, *args, **kwargs) -> Self: - """Build BaseStatusResponse and check is it valid. - - :param args: Arguments in specific realisation. - :param kwargs: Keyword arguments in specific realisation. - :return: :class:`BaseStatusResponse` object. - """ - raise NotImplementedError("You can't use abstract methods.") - - -@dataclass(frozen=True) -class JavaStatusResponse(BaseStatusResponse): - """The response object for :meth:`JavaServer.status() `.""" - - raw: RawJavaResponse - """Raw response from the server. - - This is :class:`~typing.TypedDict` actually, please see sources to find what is here. - """ - players: JavaStatusPlayers - version: JavaStatusVersion - enforces_secure_chat: bool | None - """Whether the server enforces secure chat (every message is signed up with a key). - - .. seealso:: - `Signed Chat explanation `_, - `22w17a changelog, where this was added `_. - - .. versionadded:: 11.1.0 - """ - icon: str | None - """The icon of the server. In `Base64 `_ encoded PNG image format. - - .. seealso:: :ref:`pages/faq:how to get server image?` - """ - forge_data: ForgeData | None - """Forge mod data (mod list, channels, etc). Only present if this is a forge (modded) server.""" - - @classmethod - def build(cls, raw: RawJavaResponse, latency: float = 0) -> Self: - """Build JavaStatusResponse and check is it valid. - - :param raw: Raw response :class:`dict`. - :param latency: Time that server took to response (in milliseconds). - :raise ValueError: If the required keys (``players``, ``version``, ``description``) are not present. - :raise TypeError: - If the required keys (``players`` - :class:`dict`, ``version`` - :class:`dict`, - ``description`` - :class:`str`) are not of the expected type. - :return: :class:`JavaStatusResponse` object. - """ - forge_data: ForgeData | None = None - if "forgeData" in raw or "modinfo" in raw: - raw_forge = raw.get("forgeData") or raw.get("modinfo") - assert raw_forge is not None - forge_data = ForgeData.build(raw_forge) - - return cls( - raw=raw, - players=JavaStatusPlayers.build(raw["players"]), - version=JavaStatusVersion.build(raw["version"]), - motd=Motd.parse(raw["description"], bedrock=False), - enforces_secure_chat=raw.get("enforcesSecureChat"), - icon=raw.get("favicon"), - latency=latency, - forge_data=forge_data, - ) - - -@dataclass(frozen=True) -class BedrockStatusResponse(BaseStatusResponse): - """The response object for :meth:`BedrockServer.status() `.""" - - players: BedrockStatusPlayers - version: BedrockStatusVersion - map_name: str | None - """The name of the map.""" - gamemode: str | None - """The name of the gamemode on the server.""" - - @classmethod - def build(cls, decoded_data: list[Any], latency: float) -> Self: - """Build BaseStatusResponse and check is it valid. - - :param decoded_data: Raw decoded response object. - :param latency: Latency of the request. - :return: :class:`BedrockStatusResponse` object. - """ - - try: - map_name = decoded_data[7] - except IndexError: - map_name = None - try: - gamemode = decoded_data[8] - except IndexError: - gamemode = None - - return cls( - players=BedrockStatusPlayers( - online=int(decoded_data[4]), - max=int(decoded_data[5]), - ), - version=BedrockStatusVersion( - name=decoded_data[3], - protocol=int(decoded_data[2]), - brand=decoded_data[0], - ), - motd=Motd.parse(decoded_data[1], bedrock=True), - latency=latency, - map_name=map_name, - gamemode=gamemode, - ) - - -@dataclass(frozen=True) -class BaseStatusPlayers(ABC): - """Class for storing information about players on the server.""" - - online: int - """Current number of online players.""" - max: int - """The maximum allowed number of players (aka server slots).""" - - -@dataclass(frozen=True) -class JavaStatusPlayers(BaseStatusPlayers): - """Class for storing information about players on the server.""" - - sample: list[JavaStatusPlayer] | None - """List of players, who are online. If server didn't provide this, it will be :obj:`None`. - - Actually, this is what appears when you hover over the slot count on the multiplayer screen. - - .. note:: - It's often empty or even contains some advertisement, because the specific server implementations or plugins can - disable providing this information or even change it to something custom. - - There is nothing that ``mcstatus`` can to do here if the player sample was modified/disabled like this. - """ - - @classmethod - def build(cls, raw: RawJavaResponsePlayers) -> Self: - """Build :class:`JavaStatusPlayers` from raw response :class:`dict`. - - :param raw: Raw response :class:`dict`. - :raise ValueError: If the required keys (``online``, ``max``) are not present. - :raise TypeError: - If the required keys (``online`` - :class:`int`, ``max`` - :class:`int`, - ``sample`` - :class:`list`) are not of the expected type. - :return: :class:`JavaStatusPlayers` object. - """ - sample = None - if "sample" in raw: - sample = [JavaStatusPlayer.build(player) for player in raw["sample"]] - return cls( - online=raw["online"], - max=raw["max"], - sample=sample, - ) - - -@dataclass(frozen=True) -class BedrockStatusPlayers(BaseStatusPlayers): - """Class for storing information about players on the server.""" - - -@dataclass(frozen=True) -class JavaStatusPlayer: - """Class with information about a single player.""" - - name: str - """Name of the player.""" - id: str - """ID of the player (in `UUID `_ format).""" - - @property - def uuid(self) -> str: - """Alias to :attr:`.id` field.""" - return self.id - - @classmethod - def build(cls, raw: RawJavaResponsePlayer) -> Self: - """Build :class:`JavaStatusPlayer` from raw response :class:`dict`. - - :param raw: Raw response :class:`dict`. - :raise ValueError: If the required keys (``name``, ``id``) are not present. - :raise TypeError: If the required keys (``name`` - :class:`str`, ``id`` - :class:`str`) - are not of the expected type. - :return: :class:`JavaStatusPlayer` object. - """ - return cls(name=raw["name"], id=raw["id"]) - - -@dataclass(frozen=True) -class BaseStatusVersion(ABC): - """A class for storing version information.""" - - name: str - """The version name, like ``1.19.3``. - - See `Minecraft wiki `__ - for complete list. - """ - protocol: int - """The protocol version, like ``761``. - - See `Minecraft wiki `__. - """ - - -@dataclass(frozen=True) -class JavaStatusVersion(BaseStatusVersion): - """A class for storing version information.""" - - @classmethod - def build(cls, raw: RawJavaResponseVersion) -> Self: - """Build :class:`JavaStatusVersion` from raw response dict. - - :param raw: Raw response :class:`dict`. - :raise ValueError: If the required keys (``name``, ``protocol``) are not present. - :raise TypeError: If the required keys (``name`` - :class:`str`, ``protocol`` - :class:`int`) - are not of the expected type. - :return: :class:`JavaStatusVersion` object. - """ - return cls(name=raw["name"], protocol=raw["protocol"]) - - -@dataclass(frozen=True) -class BedrockStatusVersion(BaseStatusVersion): - """A class for storing version information.""" - - name: str - """The version name, like ``1.19.60``. +import warnings - See `Minecraft wiki `__ - for complete list. - """ - brand: str - """``MCPE`` or ``MCEE`` for Education Edition.""" +warnings.warn( + "`mcstatus.status_response` is deprecated, and will be removed at 2024-12, use `mcstatus.responses` instead", + DeprecationWarning, + stacklevel=2, +) diff --git a/poetry.lock b/poetry.lock index 3d11db71..d1e9efe8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -321,63 +321,63 @@ files = [ [[package]] name = "coverage" -version = "7.5.2" +version = "7.5.3" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.5.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:554c7327bf0fd688050348e22db7c8e163fb7219f3ecdd4732d7ed606b417263"}, - {file = "coverage-7.5.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d0305e02e40c7cfea5d08d6368576537a74c0eea62b77633179748d3519d6705"}, - {file = "coverage-7.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:829fb55ad437d757c70d5b1c51cfda9377f31506a0a3f3ac282bc6a387d6a5f1"}, - {file = "coverage-7.5.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:894b1acded706f1407a662d08e026bfd0ff1e59e9bd32062fea9d862564cfb65"}, - {file = "coverage-7.5.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fe76d6dee5e4febefa83998b17926df3a04e5089e3d2b1688c74a9157798d7a2"}, - {file = "coverage-7.5.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:c7ebf2a37e4f5fea3c1a11e1f47cea7d75d0f2d8ef69635ddbd5c927083211fc"}, - {file = "coverage-7.5.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20e611fc36e1a0fc7bbf957ef9c635c8807d71fbe5643e51b2769b3cc0fb0b51"}, - {file = "coverage-7.5.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7c5c5b7ae2763533152880d5b5b451acbc1089ade2336b710a24b2b0f5239d20"}, - {file = "coverage-7.5.2-cp310-cp310-win32.whl", hash = "sha256:1e4225990a87df898e40ca31c9e830c15c2c53b1d33df592bc8ef314d71f0281"}, - {file = "coverage-7.5.2-cp310-cp310-win_amd64.whl", hash = "sha256:976cd92d9420e6e2aa6ce6a9d61f2b490e07cb468968adf371546b33b829284b"}, - {file = "coverage-7.5.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5997d418c219dcd4dcba64e50671cca849aaf0dac3d7a2eeeb7d651a5bd735b8"}, - {file = "coverage-7.5.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ec27e93bbf5976f0465e8936f02eb5add99bbe4e4e7b233607e4d7622912d68d"}, - {file = "coverage-7.5.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f11f98753800eb1ec872562a398081f6695f91cd01ce39819e36621003ec52a"}, - {file = "coverage-7.5.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e34680049eecb30b6498784c9637c1c74277dcb1db75649a152f8004fbd6646"}, - {file = "coverage-7.5.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3e12536446ad4527ac8ed91d8a607813085683bcce27af69e3b31cd72b3c5960"}, - {file = "coverage-7.5.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:3d3f7744b8a8079d69af69d512e5abed4fb473057625588ce126088e50d05493"}, - {file = "coverage-7.5.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:431a3917e32223fcdb90b79fe60185864a9109631ebc05f6c5aa03781a00b513"}, - {file = "coverage-7.5.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a7c6574225f34ce45466f04751d957b5c5e6b69fca9351db017c9249786172ce"}, - {file = "coverage-7.5.2-cp311-cp311-win32.whl", hash = "sha256:2b144d142ec9987276aeff1326edbc0df8ba4afbd7232f0ca10ad57a115e95b6"}, - {file = "coverage-7.5.2-cp311-cp311-win_amd64.whl", hash = "sha256:900532713115ac58bc3491b9d2b52704a05ed408ba0918d57fd72c94bc47fba1"}, - {file = "coverage-7.5.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:9a42970ce74c88bdf144df11c52c5cf4ad610d860de87c0883385a1c9d9fa4ab"}, - {file = "coverage-7.5.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:26716a1118c6ce2188283b4b60a898c3be29b480acbd0a91446ced4fe4e780d8"}, - {file = "coverage-7.5.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60b66b0363c5a2a79fba3d1cd7430c25bbd92c923d031cae906bdcb6e054d9a2"}, - {file = "coverage-7.5.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5d22eba19273b2069e4efeff88c897a26bdc64633cbe0357a198f92dca94268"}, - {file = "coverage-7.5.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3bb5b92a0ab3d22dfdbfe845e2fef92717b067bdf41a5b68c7e3e857c0cff1a4"}, - {file = "coverage-7.5.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1aef719b6559b521ae913ddeb38f5048c6d1a3d366865e8b320270b7bc4693c2"}, - {file = "coverage-7.5.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8809c0ea0e8454f756e3bd5c36d04dddf222989216788a25bfd6724bfcee342c"}, - {file = "coverage-7.5.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1acc2e2ef098a1d4bf535758085f508097316d738101a97c3f996bccba963ea5"}, - {file = "coverage-7.5.2-cp312-cp312-win32.whl", hash = "sha256:97de509043d3f0f2b2cd171bdccf408f175c7f7a99d36d566b1ae4dd84107985"}, - {file = "coverage-7.5.2-cp312-cp312-win_amd64.whl", hash = "sha256:8941e35a0e991a7a20a1fa3e3182f82abe357211f2c335a9e6007067c3392fcf"}, - {file = "coverage-7.5.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5662bf0f6fb6757f5c2d6279c541a5af55a39772c2362ed0920b27e3ce0e21f7"}, - {file = "coverage-7.5.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3d9c62cff2ffb4c2a95328488fd7aa96a7a4b34873150650fe76b19c08c9c792"}, - {file = "coverage-7.5.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74eeaa13e8200ad72fca9c5f37395fb310915cec6f1682b21375e84fd9770e84"}, - {file = "coverage-7.5.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f29bf497d51a5077994b265e976d78b09d9d0dff6ca5763dbb4804534a5d380"}, - {file = "coverage-7.5.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f96aa94739593ae0707eda9813ce363a0a0374a810ae0eced383340fc4a1f73"}, - {file = "coverage-7.5.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:51b6cee539168a912b4b3b040e4042b9e2c9a7ad9c8546c09e4eaeff3eacba6b"}, - {file = "coverage-7.5.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:59a75e6aa5c25b50b5a1499f9718f2edff54257f545718c4fb100f48d570ead4"}, - {file = "coverage-7.5.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:29da75ce20cb0a26d60e22658dd3230713c6c05a3465dd8ad040ffc991aea318"}, - {file = "coverage-7.5.2-cp38-cp38-win32.whl", hash = "sha256:23f2f16958b16152b43a39a5ecf4705757ddd284b3b17a77da3a62aef9c057ef"}, - {file = "coverage-7.5.2-cp38-cp38-win_amd64.whl", hash = "sha256:9e41c94035e5cdb362beed681b58a707e8dc29ea446ea1713d92afeded9d1ddd"}, - {file = "coverage-7.5.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:06d96b9b19bbe7f049c2be3c4f9e06737ec6d8ef8933c7c3a4c557ef07936e46"}, - {file = "coverage-7.5.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:878243e1206828908a6b4a9ca7b1aa8bee9eb129bf7186fc381d2646f4524ce9"}, - {file = "coverage-7.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:482df956b055d3009d10fce81af6ffab28215d7ed6ad4a15e5c8e67cb7c5251c"}, - {file = "coverage-7.5.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a35c97af60a5492e9e89f8b7153fe24eadfd61cb3a2fb600df1a25b5dab34b7e"}, - {file = "coverage-7.5.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24bb4c7859a3f757a116521d4d3a8a82befad56ea1bdacd17d6aafd113b0071e"}, - {file = "coverage-7.5.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:e1046aab24c48c694f0793f669ac49ea68acde6a0798ac5388abe0a5615b5ec8"}, - {file = "coverage-7.5.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:448ec61ea9ea7916d5579939362509145caaecf03161f6f13e366aebb692a631"}, - {file = "coverage-7.5.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4a00bd5ba8f1a4114720bef283cf31583d6cb1c510ce890a6da6c4268f0070b7"}, - {file = "coverage-7.5.2-cp39-cp39-win32.whl", hash = "sha256:9f805481d5eff2a96bac4da1570ef662bf970f9a16580dc2c169c8c3183fa02b"}, - {file = "coverage-7.5.2-cp39-cp39-win_amd64.whl", hash = "sha256:2c79f058e7bec26b5295d53b8c39ecb623448c74ccc8378631f5cb5c16a7e02c"}, - {file = "coverage-7.5.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:40dbb8e7727560fe8ab65efcddfec1ae25f30ef02e2f2e5d78cfb52a66781ec5"}, - {file = "coverage-7.5.2.tar.gz", hash = "sha256:13017a63b0e499c59b5ba94a8542fb62864ba3016127d1e4ef30d354fc2b00e9"}, + {file = "coverage-7.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a6519d917abb15e12380406d721e37613e2a67d166f9fb7e5a8ce0375744cd45"}, + {file = "coverage-7.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:aea7da970f1feccf48be7335f8b2ca64baf9b589d79e05b9397a06696ce1a1ec"}, + {file = "coverage-7.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:923b7b1c717bd0f0f92d862d1ff51d9b2b55dbbd133e05680204465f454bb286"}, + {file = "coverage-7.5.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62bda40da1e68898186f274f832ef3e759ce929da9a9fd9fcf265956de269dbc"}, + {file = "coverage-7.5.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8b7339180d00de83e930358223c617cc343dd08e1aa5ec7b06c3a121aec4e1d"}, + {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:25a5caf742c6195e08002d3b6c2dd6947e50efc5fc2c2205f61ecb47592d2d83"}, + {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:05ac5f60faa0c704c0f7e6a5cbfd6f02101ed05e0aee4d2822637a9e672c998d"}, + {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:239a4e75e09c2b12ea478d28815acf83334d32e722e7433471fbf641c606344c"}, + {file = "coverage-7.5.3-cp310-cp310-win32.whl", hash = "sha256:a5812840d1d00eafae6585aba38021f90a705a25b8216ec7f66aebe5b619fb84"}, + {file = "coverage-7.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:33ca90a0eb29225f195e30684ba4a6db05dbef03c2ccd50b9077714c48153cac"}, + {file = "coverage-7.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f81bc26d609bf0fbc622c7122ba6307993c83c795d2d6f6f6fd8c000a770d974"}, + {file = "coverage-7.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7cec2af81f9e7569280822be68bd57e51b86d42e59ea30d10ebdbb22d2cb7232"}, + {file = "coverage-7.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55f689f846661e3f26efa535071775d0483388a1ccfab899df72924805e9e7cd"}, + {file = "coverage-7.5.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:50084d3516aa263791198913a17354bd1dc627d3c1639209640b9cac3fef5807"}, + {file = "coverage-7.5.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:341dd8f61c26337c37988345ca5c8ccabeff33093a26953a1ac72e7d0103c4fb"}, + {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ab0b028165eea880af12f66086694768f2c3139b2c31ad5e032c8edbafca6ffc"}, + {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5bc5a8c87714b0c67cfeb4c7caa82b2d71e8864d1a46aa990b5588fa953673b8"}, + {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:38a3b98dae8a7c9057bd91fbf3415c05e700a5114c5f1b5b0ea5f8f429ba6614"}, + {file = "coverage-7.5.3-cp311-cp311-win32.whl", hash = "sha256:fcf7d1d6f5da887ca04302db8e0e0cf56ce9a5e05f202720e49b3e8157ddb9a9"}, + {file = "coverage-7.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:8c836309931839cca658a78a888dab9676b5c988d0dd34ca247f5f3e679f4e7a"}, + {file = "coverage-7.5.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:296a7d9bbc598e8744c00f7a6cecf1da9b30ae9ad51c566291ff1314e6cbbed8"}, + {file = "coverage-7.5.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:34d6d21d8795a97b14d503dcaf74226ae51eb1f2bd41015d3ef332a24d0a17b3"}, + {file = "coverage-7.5.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e317953bb4c074c06c798a11dbdd2cf9979dbcaa8ccc0fa4701d80042d4ebf1"}, + {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:705f3d7c2b098c40f5b81790a5fedb274113373d4d1a69e65f8b68b0cc26f6db"}, + {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1196e13c45e327d6cd0b6e471530a1882f1017eb83c6229fc613cd1a11b53cd"}, + {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:015eddc5ccd5364dcb902eaecf9515636806fa1e0d5bef5769d06d0f31b54523"}, + {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fd27d8b49e574e50caa65196d908f80e4dff64d7e592d0c59788b45aad7e8b35"}, + {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:33fc65740267222fc02975c061eb7167185fef4cc8f2770267ee8bf7d6a42f84"}, + {file = "coverage-7.5.3-cp312-cp312-win32.whl", hash = "sha256:7b2a19e13dfb5c8e145c7a6ea959485ee8e2204699903c88c7d25283584bfc08"}, + {file = "coverage-7.5.3-cp312-cp312-win_amd64.whl", hash = "sha256:0bbddc54bbacfc09b3edaec644d4ac90c08ee8ed4844b0f86227dcda2d428fcb"}, + {file = "coverage-7.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f78300789a708ac1f17e134593f577407d52d0417305435b134805c4fb135adb"}, + {file = "coverage-7.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b368e1aee1b9b75757942d44d7598dcd22a9dbb126affcbba82d15917f0cc155"}, + {file = "coverage-7.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f836c174c3a7f639bded48ec913f348c4761cbf49de4a20a956d3431a7c9cb24"}, + {file = "coverage-7.5.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:244f509f126dc71369393ce5fea17c0592c40ee44e607b6d855e9c4ac57aac98"}, + {file = "coverage-7.5.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4c2872b3c91f9baa836147ca33650dc5c172e9273c808c3c3199c75490e709d"}, + {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:dd4b3355b01273a56b20c219e74e7549e14370b31a4ffe42706a8cda91f19f6d"}, + {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:f542287b1489c7a860d43a7d8883e27ca62ab84ca53c965d11dac1d3a1fab7ce"}, + {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:75e3f4e86804023e991096b29e147e635f5e2568f77883a1e6eed74512659ab0"}, + {file = "coverage-7.5.3-cp38-cp38-win32.whl", hash = "sha256:c59d2ad092dc0551d9f79d9d44d005c945ba95832a6798f98f9216ede3d5f485"}, + {file = "coverage-7.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:fa21a04112c59ad54f69d80e376f7f9d0f5f9123ab87ecd18fbb9ec3a2beed56"}, + {file = "coverage-7.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f5102a92855d518b0996eb197772f5ac2a527c0ec617124ad5242a3af5e25f85"}, + {file = "coverage-7.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d1da0a2e3b37b745a2b2a678a4c796462cf753aebf94edcc87dcc6b8641eae31"}, + {file = "coverage-7.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8383a6c8cefba1b7cecc0149415046b6fc38836295bc4c84e820872eb5478b3d"}, + {file = "coverage-7.5.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9aad68c3f2566dfae84bf46295a79e79d904e1c21ccfc66de88cd446f8686341"}, + {file = "coverage-7.5.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e079c9ec772fedbade9d7ebc36202a1d9ef7291bc9b3a024ca395c4d52853d7"}, + {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:bde997cac85fcac227b27d4fb2c7608a2c5f6558469b0eb704c5726ae49e1c52"}, + {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:990fb20b32990b2ce2c5f974c3e738c9358b2735bc05075d50a6f36721b8f303"}, + {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3d5a67f0da401e105753d474369ab034c7bae51a4c31c77d94030d59e41df5bd"}, + {file = "coverage-7.5.3-cp39-cp39-win32.whl", hash = "sha256:e08c470c2eb01977d221fd87495b44867a56d4d594f43739a8028f8646a51e0d"}, + {file = "coverage-7.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:1d2a830ade66d3563bb61d1e3c77c8def97b30ed91e166c67d0632c018f380f0"}, + {file = "coverage-7.5.3-pp38.pp39.pp310-none-any.whl", hash = "sha256:3538d8fb1ee9bdd2e2692b3b18c22bb1c19ffbefd06880f5ac496e42d7bb3884"}, + {file = "coverage-7.5.3.tar.gz", hash = "sha256:04aefca5190d1dc7a53a4c1a5a7f8568811306d7a8ee231c42fb69215571944f"}, ] [package.dependencies] @@ -1631,28 +1631,28 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.4.5" +version = "0.4.7" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.4.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:8f58e615dec58b1a6b291769b559e12fdffb53cc4187160a2fc83250eaf54e96"}, - {file = "ruff-0.4.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:84dd157474e16e3a82745d2afa1016c17d27cb5d52b12e3d45d418bcc6d49264"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25f483ad9d50b00e7fd577f6d0305aa18494c6af139bce7319c68a17180087f4"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:63fde3bf6f3ad4e990357af1d30e8ba2730860a954ea9282c95fc0846f5f64af"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:78e3ba4620dee27f76bbcad97067766026c918ba0f2d035c2fc25cbdd04d9c97"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:441dab55c568e38d02bbda68a926a3d0b54f5510095c9de7f95e47a39e0168aa"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1169e47e9c4136c997f08f9857ae889d614c5035d87d38fda9b44b4338909cdf"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:755ac9ac2598a941512fc36a9070a13c88d72ff874a9781493eb237ab02d75df"}, - {file = "ruff-0.4.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4b02a65985be2b34b170025a8b92449088ce61e33e69956ce4d316c0fe7cce0"}, - {file = "ruff-0.4.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:75a426506a183d9201e7e5664de3f6b414ad3850d7625764106f7b6d0486f0a1"}, - {file = "ruff-0.4.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6e1b139b45e2911419044237d90b60e472f57285950e1492c757dfc88259bb06"}, - {file = "ruff-0.4.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a6f29a8221d2e3d85ff0c7b4371c0e37b39c87732c969b4d90f3dad2e721c5b1"}, - {file = "ruff-0.4.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d6ef817124d72b54cc923f3444828ba24fa45c3164bc9e8f1813db2f3d3a8a11"}, - {file = "ruff-0.4.5-py3-none-win32.whl", hash = "sha256:aed8166c18b1a169a5d3ec28a49b43340949e400665555b51ee06f22813ef062"}, - {file = "ruff-0.4.5-py3-none-win_amd64.whl", hash = "sha256:b0b03c619d2b4350b4a27e34fd2ac64d0dabe1afbf43de57d0f9d8a05ecffa45"}, - {file = "ruff-0.4.5-py3-none-win_arm64.whl", hash = "sha256:9d15de3425f53161b3f5a5658d4522e4eee5ea002bf2ac7aa380743dd9ad5fba"}, - {file = "ruff-0.4.5.tar.gz", hash = "sha256:286eabd47e7d4d521d199cab84deca135557e6d1e0f0d01c29e757c3cb151b54"}, + {file = "ruff-0.4.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e089371c67892a73b6bb1525608e89a2aca1b77b5440acf7a71dda5dac958f9e"}, + {file = "ruff-0.4.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:10f973d521d910e5f9c72ab27e409e839089f955be8a4c8826601a6323a89753"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:59c3d110970001dfa494bcd95478e62286c751126dfb15c3c46e7915fc49694f"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fa9773c6c00f4958f73b317bc0fd125295110c3776089f6ef318f4b775f0abe4"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07fc80bbb61e42b3b23b10fda6a2a0f5a067f810180a3760c5ef1b456c21b9db"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:fa4dafe3fe66d90e2e2b63fa1591dd6e3f090ca2128daa0be33db894e6c18648"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7c0083febdec17571455903b184a10026603a1de078428ba155e7ce9358c5f6"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ad1b20e66a44057c326168437d680a2166c177c939346b19c0d6b08a62a37589"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbf5d818553add7511c38b05532d94a407f499d1a76ebb0cad0374e32bc67202"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:50e9651578b629baec3d1513b2534de0ac7ed7753e1382272b8d609997e27e83"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8874a9df7766cb956b218a0a239e0a5d23d9e843e4da1e113ae1d27ee420877a"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b9de9a6e49f7d529decd09381c0860c3f82fa0b0ea00ea78409b785d2308a567"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:13a1768b0691619822ae6d446132dbdfd568b700ecd3652b20d4e8bc1e498f78"}, + {file = "ruff-0.4.7-py3-none-win32.whl", hash = "sha256:769e5a51df61e07e887b81e6f039e7ed3573316ab7dd9f635c5afaa310e4030e"}, + {file = "ruff-0.4.7-py3-none-win_amd64.whl", hash = "sha256:9e3ab684ad403a9ed1226894c32c3ab9c2e0718440f6f50c7c5829932bc9e054"}, + {file = "ruff-0.4.7-py3-none-win_arm64.whl", hash = "sha256:10f2204b9a613988e3484194c2c9e96a22079206b22b787605c255f130db5ed7"}, + {file = "ruff-0.4.7.tar.gz", hash = "sha256:2331d2b051dc77a289a653fcc6a42cce357087c5975738157cd966590b18b5e1"}, ] [[package]] @@ -2020,13 +2020,13 @@ urllib3 = ">=1.26.0" [[package]] name = "typing-extensions" -version = "4.12.0" +version = "4.12.1" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.12.0-py3-none-any.whl", hash = "sha256:b349c66bea9016ac22978d800cfff206d5f9816951f12a7d0ec5578b0a819594"}, - {file = "typing_extensions-4.12.0.tar.gz", hash = "sha256:8cbcdc8606ebcb0d95453ad7dc5065e6237b6aa230a31e81d0f440c30fed5fd8"}, + {file = "typing_extensions-4.12.1-py3-none-any.whl", hash = "sha256:6024b58b69089e5a89c347397254e35f1bf02a907728ec7fee9bf0fe837d203a"}, + {file = "typing_extensions-4.12.1.tar.gz", hash = "sha256:915f5e35ff76f56588223f15fdd5938f9a1cf9195c0de25130c627e4d597f6d1"}, ] [[package]] @@ -2167,4 +2167,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4" -content-hash = "b64e4a1fee3c50163df925155aaff634d98d7ffd02aeb905bfc17a4a23e68c00" +content-hash = "c3cf788ec97dd4bfabc3ca218e0dffc15870941b52fe77e5f876dea6ea9b0fb4" diff --git a/pyproject.toml b/pyproject.toml index bb04cfcd..8ef9f93d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ pytest-rerunfailures = ">=13,<15" coverage = "^7.3.0" [tool.poetry.group.lint.dependencies] -ruff = "0.4.5" +ruff = "0.4.7" coverage = "^7.3.0" pyright = "^1.1.322" typing-extensions = "^4.7.1" diff --git a/tests/motd/test_motd.py b/tests/motd/test_motd.py index 151b72d7..3012d603 100644 --- a/tests/motd/test_motd.py +++ b/tests/motd/test_motd.py @@ -4,7 +4,7 @@ from mcstatus.motd import Motd from mcstatus.motd.components import Formatting, MinecraftColor, TranslationTag, WebColor -from mcstatus.status_response import RawJavaResponseMotdWhenDict +from mcstatus.responses import RawJavaResponseMotdWhenDict class TestMotdParse: diff --git a/tests/motd/test_transformers.py b/tests/motd/test_transformers.py index 5d9fce0a..0c73f9e4 100644 --- a/tests/motd/test_transformers.py +++ b/tests/motd/test_transformers.py @@ -9,7 +9,7 @@ from mcstatus.motd.transformers import AnsiTransformer, HtmlTransformer, MinecraftTransformer, PlainTransformer if typing.TYPE_CHECKING: - from mcstatus.status_response import RawJavaResponseMotd + from mcstatus.responses import RawJavaResponseMotd class TestMotdPlain: diff --git a/tests/status_response/__init__.py b/tests/responses/__init__.py similarity index 93% rename from tests/status_response/__init__.py rename to tests/responses/__init__.py index ca9a8d63..59c09b36 100644 --- a/tests/status_response/__init__.py +++ b/tests/responses/__init__.py @@ -3,18 +3,18 @@ import abc from typing import Any, TypeVar, cast -from mcstatus.status_response import BaseStatusResponse +from mcstatus.responses import BaseStatusResponse -__all__ = ["BaseStatusResponseTest"] -_T = TypeVar("_T", bound="type[BaseStatusResponseTest]") +__all__ = ["BaseResponseTest"] +_T = TypeVar("_T", bound="type[BaseResponseTest]") -class BaseStatusResponseTest(abc.ABC): +class BaseResponseTest(abc.ABC): EXPECTED_VALUES: list[tuple[str, Any]] | None = None EXPECTED_TYPES: list[tuple[str, type]] | None = None ATTRIBUTES_IN: list[str] | None = None # if we don't specify item in raw answer, target field will be None - # first element is a list with fields to remove, and attribute that + # a first element is a list with fields to remove, and attribute that # must be None. a dict is a raw answer to pass into `build` method OPTIONAL_FIELDS: tuple[list[tuple[str, str]], dict[str, Any]] | None = None @@ -89,7 +89,7 @@ def _marks_table(self) -> dict[str, tuple[str, tuple[Any, ...]]]: @staticmethod def construct(class_: _T) -> _T: - instance: BaseStatusResponseTest = class_() # type: ignore + instance: BaseResponseTest = class_() # type: ignore instance._validate() for implementation_name, meet_dependencies in instance._dependency_table().items(): if not meet_dependencies: diff --git a/tests/status_response/conftest.py b/tests/responses/conftest.py similarity index 83% rename from tests/status_response/conftest.py rename to tests/responses/conftest.py index 153b2025..b2b29f50 100644 --- a/tests/status_response/conftest.py +++ b/tests/responses/conftest.py @@ -5,11 +5,11 @@ import pytest from _pytest.python import Function, Metafunc -from tests.status_response import BaseStatusResponseTest +from tests.responses import BaseResponseTest def pytest_generate_tests(metafunc: Metafunc) -> None: - if issubclass(typing.cast(type, metafunc.cls), BaseStatusResponseTest): + if issubclass(typing.cast(type, metafunc.cls), BaseResponseTest): instance = typing.cast(type, metafunc.cls)() if metafunc.definition.name not in instance._marks_table().keys(): return @@ -22,7 +22,7 @@ def pytest_generate_tests(metafunc: Metafunc) -> None: def pytest_collection_modifyitems(items: list[Function]) -> None: for item in items: - if isinstance(item.instance, BaseStatusResponseTest): + if isinstance(item.instance, BaseResponseTest): if item.obj.__name__ not in item.instance._marks_table().keys(): continue diff --git a/tests/status_response/test_bedrock.py b/tests/responses/test_bedrock.py similarity index 82% rename from tests/status_response/test_bedrock.py rename to tests/responses/test_bedrock.py index 7b8cd2c4..8281b24b 100644 --- a/tests/status_response/test_bedrock.py +++ b/tests/responses/test_bedrock.py @@ -1,8 +1,8 @@ from pytest import fixture, mark from mcstatus.motd import Motd -from mcstatus.status_response import BedrockStatusPlayers, BedrockStatusResponse, BedrockStatusVersion -from tests.status_response import BaseStatusResponseTest +from mcstatus.responses import BedrockStatusPlayers, BedrockStatusResponse, BedrockStatusVersion +from tests.responses import BaseResponseTest @fixture(scope="module") @@ -27,8 +27,8 @@ def build(): ) -@BaseStatusResponseTest.construct -class TestBedrockStatusResponse(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestBedrockStatusResponse(BaseResponseTest): EXPECTED_VALUES = [ ("motd", Motd.parse("§r§4G§r§6a§r§ey§r§2B§r§1o§r§9w§r§ds§r§4e§r§6r", bedrock=True)), ("latency", 123.0), @@ -66,8 +66,8 @@ def test_optional_parameters_is_none(self, field, pop_index): assert getattr(build, field) is None -@BaseStatusResponseTest.construct -class TestBedrockStatusPlayers(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestBedrockStatusPlayers(BaseResponseTest): EXPECTED_VALUES = [("online", 1), ("max", 69)] @fixture(scope="class") @@ -75,8 +75,8 @@ def build(self, build): return build.players -@BaseStatusResponseTest.construct -class TestBedrockStatusVersion(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestBedrockStatusVersion(BaseResponseTest): EXPECTED_VALUES = [("name", "1.18.100500"), ("protocol", 422), ("brand", "MCPE")] @fixture(scope="class") diff --git a/tests/status_response/test_forge_data.py b/tests/responses/test_forge_data.py similarity index 99% rename from tests/status_response/test_forge_data.py rename to tests/responses/test_forge_data.py index 11b8857b..dd81414c 100644 --- a/tests/status_response/test_forge_data.py +++ b/tests/responses/test_forge_data.py @@ -1,11 +1,11 @@ import pytest from mcstatus.forge_data import ForgeData, ForgeDataChannel, ForgeDataMod, RawForgeData -from tests.status_response import BaseStatusResponseTest +from tests.responses import BaseResponseTest -@BaseStatusResponseTest.construct -class TestForgeDataV1(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestForgeDataV1(BaseResponseTest): RAW = { "type": "FML", "modList": [ @@ -39,8 +39,8 @@ def build(self) -> ForgeData: return ForgeData.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict -@BaseStatusResponseTest.construct -class TestForgeDataV2(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestForgeDataV2(BaseResponseTest): RAW = { "fmlNetworkVersion": 2, "channels": [ @@ -63,8 +63,8 @@ def build(self) -> ForgeData: return ForgeData.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict -@BaseStatusResponseTest.construct -class TestForgeDataV3(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestForgeDataV3(BaseResponseTest): RAW = { "channels": [], "mods": [], @@ -104,8 +104,8 @@ def build(self) -> ForgeData: return ForgeData.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict -@BaseStatusResponseTest.construct -class TestForgeData(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestForgeData(BaseResponseTest): EXPECTED_VALUES = [ ("fml_network_version", 3), ( diff --git a/tests/status_response/test_java.py b/tests/responses/test_java.py similarity index 86% rename from tests/status_response/test_java.py rename to tests/responses/test_java.py index 5156d32d..256cafcd 100644 --- a/tests/status_response/test_java.py +++ b/tests/responses/test_java.py @@ -1,12 +1,12 @@ import pytest from mcstatus.motd import Motd -from mcstatus.status_response import JavaStatusPlayer, JavaStatusPlayers, JavaStatusResponse, JavaStatusVersion -from tests.status_response import BaseStatusResponseTest +from mcstatus.responses import JavaStatusPlayer, JavaStatusPlayers, JavaStatusResponse, JavaStatusVersion +from tests.responses import BaseResponseTest -@BaseStatusResponseTest.construct -class TestJavaStatusResponse(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestJavaStatusResponse(BaseResponseTest): RAW = { "players": {"max": 20, "online": 0}, "version": {"name": "1.8-pre1", "protocol": 44}, @@ -41,8 +41,8 @@ def build(self) -> JavaStatusResponse: return JavaStatusResponse.build(self.RAW) # type: ignore # dict[str, Unknown] cannot be assigned to TypedDict -@BaseStatusResponseTest.construct -class TestJavaStatusPlayers(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestJavaStatusPlayers(BaseResponseTest): EXPECTED_VALUES = [ ("max", 20), ("online", 0), @@ -86,8 +86,8 @@ def test_empty_sample_turns_into_empty_list(self) -> None: assert JavaStatusPlayers.build({"max": 20, "online": 0, "sample": []}).sample == [] -@BaseStatusResponseTest.construct -class TestJavaStatusPlayer(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestJavaStatusPlayer(BaseResponseTest): EXPECTED_VALUES = [("name", "foo"), ("id", "0b3717c4-f45d-47c8-b8e2-3d9ff6f93a89")] @pytest.fixture(scope="class") @@ -101,8 +101,8 @@ def test_id_field_the_same_as_uuid(self) -> None: assert build.uuid is unique -@BaseStatusResponseTest.construct -class TestJavaStatusVersion(BaseStatusResponseTest): +@BaseResponseTest.construct +class TestJavaStatusVersion(BaseResponseTest): EXPECTED_VALUES = [("name", "1.8-pre1"), ("protocol", 44)] @pytest.fixture(scope="class") diff --git a/tests/status_response/test_shared.py b/tests/responses/test_shared.py similarity index 81% rename from tests/status_response/test_shared.py rename to tests/responses/test_shared.py index 5183695a..acd6f884 100644 --- a/tests/status_response/test_shared.py +++ b/tests/responses/test_shared.py @@ -1,6 +1,6 @@ from pytest import raises -from mcstatus.status_response import BaseStatusResponse +from mcstatus.responses import BaseStatusResponse class TestMCStatusResponse: diff --git a/tests/test_bedrock_status.py b/tests/test_bedrock_status.py index be82c393..863e27a1 100644 --- a/tests/test_bedrock_status.py +++ b/tests/test_bedrock_status.py @@ -6,7 +6,7 @@ from mcstatus.address import Address from mcstatus.bedrock_status import BedrockServerStatus -from mcstatus.status_response import BedrockStatusResponse +from mcstatus.responses import BedrockStatusResponse def test_bedrock_response_is_expected_type():