Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions client/src/cbltest/api/multipeer_replicator_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ class MultipeerTransportType(Flag):
BLUETOOTH = auto()
ALL = WIFI | BLUETOOTH

@classmethod
def from_string(cls, value: str) -> "MultipeerTransportType":
value = value.upper()

if value == "WIFI":
return cls.WIFI
elif value == "BLUETOOTH":
return cls.BLUETOOTH
else:
raise ValueError(f"Unknown MultipeerTransportType: {value}")

def to_json(self) -> list[str]:
cls = type(self)
# only single-bit members, and only those present in self
Expand Down
11 changes: 11 additions & 0 deletions client/src/cbltest/response_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from typing import Any, Final, cast

from cbltest.api.error_types import ErrorResponseBody
from cbltest.api.multipeer_replicator_types import (
MultipeerTransportType,
)
from cbltest.api.replicator_types import (
ReplicatorActivityLevel,
ReplicatorDocumentEntry,
Expand Down Expand Up @@ -224,6 +227,7 @@ class MultipeerReplicatorStatusEntry:

__peer_id_key: Final[str] = "peerID"
__status_key: Final[str] = "status"
__transport_key: Final[str] = "transport"

@property
def peer_id(self) -> str:
Expand All @@ -235,13 +239,20 @@ def status(self) -> ReplicatorStatusBody:
"""Gets the status of the replicator"""
return self.__status

@property
def transport(self) -> MultipeerTransportType:
"""Gets the transport type of the replicator"""
return self.__transport

def __init__(self, body: dict):
assert isinstance(body, dict), (
"Invalid MultipeerReplicatorStatusEntry received (not an object)"
)

self.__peer_id = _assert_string_entry(body, self.__peer_id_key)
self.__status = ReplicatorStatusBody(body.get(self.__status_key, {}))
transport_str = _assert_string_entry(body, self.__transport_key)
self.__transport = MultipeerTransportType.from_string(transport_str)


class PostGetMultipeerReplicatorStatusResponseMethods(ABC):
Expand Down
1 change: 1 addition & 0 deletions client/src/cbltest/v1/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class PostGetMultipeerReplicatorStatusResponse(
{
"peerID": "1234567890abcdef",
"status": <replicator status>,
"transport": "wifi"
}
]
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension ContentTypes {
struct PeerReplicatorStatus : Content {
let peerID: String
let status: ReplicatorStatus
let transport: MultipeerTransport
}

struct MultipeerReplicatorStatus : Content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ extension ContentTypes {
case wifi = "WIFI"
case bluetooth = "BLUETOOTH"
}
}
}
Loading
Loading