Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 12 additions & 13 deletions make87/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ class TopicBaseModel(BaseModel):
message_type: str


class Priority(Enum):
# CONTROL = 0 # not part of zenoh-python for some reason
REAL_TIME = 1
INTERACTIVE_HIGH = 2
INTERACTIVE_LOW = 3
DATA_HIGH = 4
DATA = 5
DATA_LOW = 6
BACKGROUND = 7
class Priority(str, Enum):
REAL_TIME = "REAL_TIME"
INTERACTIVE_HIGH = "INTERACTIVE_HIGH"
INTERACTIVE_LOW = "INTERACTIVE_LOW"
DATA_HIGH = "DATA_HIGH"
DATA = "DATA"
DATA_LOW = "DATA_LOW"
BACKGROUND = "BACKGROUND"

DEFAULT = DATA
MIN = BACKGROUND
Expand All @@ -58,8 +57,8 @@ def to_zenoh(self):


class Reliability(Enum):
BEST_EFFORT = 0
RELIABLE = 1
BEST_EFFORT = "BEST_EFFORT"
RELIABLE = "RELIABLE"

DEFAULT = RELIABLE

Expand All @@ -75,8 +74,8 @@ def to_zenoh(self):


class CongestionControl(Enum):
DROP = 0
BLOCK = 1
DROP = "DROP"
BLOCK = "BLOCK"

DEFAULT = DROP

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/parse_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_parse_endpoints_missing_env(monkeypatch):


def test_parse_endpoints_with_congestion_control(monkeypatch):
valid_json = '{"endpoints": [{"endpoint_name": "test_endpoint", "endpoint_key": "test_key", "requester_message_type": "test_type", "provider_message_type": "test_type", "endpoint_type": "REQ", "congestion_control": 0}]}'
valid_json = '{"endpoints": [{"endpoint_name": "test_endpoint", "endpoint_key": "test_key", "requester_message_type": "test_type", "provider_message_type": "test_type", "endpoint_type": "REQ", "congestion_control": "DROP"}]}'
monkeypatch.setenv("ENDPOINTS", valid_json)
endpoints = parse_endpoints()
assert isinstance(endpoints, Endpoints)
Expand All @@ -35,7 +35,7 @@ def test_parse_endpoints_with_congestion_control(monkeypatch):


def test_parse_endpoints_with_priority(monkeypatch):
valid_json = '{"endpoints": [{"endpoint_name": "test_endpoint", "endpoint_key": "test_key", "requester_message_type": "test_type", "provider_message_type": "test_type", "endpoint_type": "REQ", "priority": 1}]}'
valid_json = '{"endpoints": [{"endpoint_name": "test_endpoint", "endpoint_key": "test_key", "requester_message_type": "test_type", "provider_message_type": "test_type", "endpoint_type": "REQ", "priority": "REAL_TIME"}]}'
monkeypatch.setenv("ENDPOINTS", valid_json)
endpoints = parse_endpoints()
assert isinstance(endpoints, Endpoints)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/utils/parse_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_parse_endpoints_missing_env(self, monkeypatch):
assert len(endpoints.endpoints) == 0

def test_parse_topics_with_congestion_control(self, monkeypatch):
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "congestion_control": 0}]}'
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "congestion_control": "DROP"}]}'
monkeypatch.setenv("TOPICS", valid_json)
topics = parse_topics()
assert isinstance(topics, Topics)
Expand All @@ -70,15 +70,15 @@ def test_parse_topics_with_express(self, monkeypatch):
assert topics.topics[0].express is False

def test_parse_topics_with_priority(self, monkeypatch):
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "priority": 1}]}'
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "priority": "REAL_TIME"}]}'
monkeypatch.setenv("TOPICS", valid_json)
topics = parse_topics()
assert isinstance(topics, Topics)
assert len(topics.topics) == 1
assert topics.topics[0].priority == Priority.REAL_TIME

def test_parse_topics_with_reliability(self, monkeypatch):
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "reliability": 1}]}'
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "reliability": "RELIABLE"}]}'
monkeypatch.setenv("TOPICS", valid_json)
topics = parse_topics()
assert isinstance(topics, Topics)
Expand Down