Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit a8235bd

Browse files
authored
Update endpoint and topic parsing tests to use string values for congestion control, priority, and reliability (#3)
1 parent 94bcbe7 commit a8235bd

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

make87/utils.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ class TopicBaseModel(BaseModel):
2424
message_type: str
2525

2626

27-
class Priority(Enum):
28-
# CONTROL = 0 # not part of zenoh-python for some reason
29-
REAL_TIME = 1
30-
INTERACTIVE_HIGH = 2
31-
INTERACTIVE_LOW = 3
32-
DATA_HIGH = 4
33-
DATA = 5
34-
DATA_LOW = 6
35-
BACKGROUND = 7
27+
class Priority(str, Enum):
28+
REAL_TIME = "REAL_TIME"
29+
INTERACTIVE_HIGH = "INTERACTIVE_HIGH"
30+
INTERACTIVE_LOW = "INTERACTIVE_LOW"
31+
DATA_HIGH = "DATA_HIGH"
32+
DATA = "DATA"
33+
DATA_LOW = "DATA_LOW"
34+
BACKGROUND = "BACKGROUND"
3635

3736
DEFAULT = DATA
3837
MIN = BACKGROUND
@@ -58,8 +57,8 @@ def to_zenoh(self):
5857

5958

6059
class Reliability(Enum):
61-
BEST_EFFORT = 0
62-
RELIABLE = 1
60+
BEST_EFFORT = "BEST_EFFORT"
61+
RELIABLE = "RELIABLE"
6362

6463
DEFAULT = RELIABLE
6564

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

7675

7776
class CongestionControl(Enum):
78-
DROP = 0
79-
BLOCK = 1
77+
DROP = "DROP"
78+
BLOCK = "BLOCK"
8079

8180
DEFAULT = DROP
8281

tests/unit/utils/parse_endpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_parse_endpoints_missing_env(monkeypatch):
2626

2727

2828
def test_parse_endpoints_with_congestion_control(monkeypatch):
29-
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}]}'
29+
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"}]}'
3030
monkeypatch.setenv("ENDPOINTS", valid_json)
3131
endpoints = parse_endpoints()
3232
assert isinstance(endpoints, Endpoints)
@@ -35,7 +35,7 @@ def test_parse_endpoints_with_congestion_control(monkeypatch):
3535

3636

3737
def test_parse_endpoints_with_priority(monkeypatch):
38-
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}]}'
38+
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"}]}'
3939
monkeypatch.setenv("ENDPOINTS", valid_json)
4040
endpoints = parse_endpoints()
4141
assert isinstance(endpoints, Endpoints)

tests/unit/utils/parse_topics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_parse_endpoints_missing_env(self, monkeypatch):
5454
assert len(endpoints.endpoints) == 0
5555

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

7272
def test_parse_topics_with_priority(self, monkeypatch):
73-
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "priority": 1}]}'
73+
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "priority": "REAL_TIME"}]}'
7474
monkeypatch.setenv("TOPICS", valid_json)
7575
topics = parse_topics()
7676
assert isinstance(topics, Topics)
7777
assert len(topics.topics) == 1
7878
assert topics.topics[0].priority == Priority.REAL_TIME
7979

8080
def test_parse_topics_with_reliability(self, monkeypatch):
81-
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "reliability": 1}]}'
81+
valid_json = '{"topics": [{"topic_name": "test_topic", "topic_key": "test_key", "message_type": "test_type", "topic_type": "PUB", "reliability": "RELIABLE"}]}'
8282
monkeypatch.setenv("TOPICS", valid_json)
8383
topics = parse_topics()
8484
assert isinstance(topics, Topics)

0 commit comments

Comments
 (0)