mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-04-05 03:13:22 +00:00
Add unit test for wrappers
This commit is contained in:
parent
b5ef345ea6
commit
437b7fc9c7
@ -47,3 +47,29 @@ def wrapper_unsubscribe(node, content_topic, timeout_s=20.0):
|
||||
content_topic=content_topic,
|
||||
timeout_s=timeout_s,
|
||||
)
|
||||
|
||||
|
||||
def wrapper_send_message(node, message, timeout_s=20.0):
|
||||
return node.send_message(
|
||||
message=message,
|
||||
timeout_s=timeout_s,
|
||||
)
|
||||
|
||||
|
||||
def wrapper_get_available_node_info_ids(node, timeout_s=20.0):
|
||||
return node.get_available_node_info_ids(
|
||||
timeout_s=timeout_s,
|
||||
)
|
||||
|
||||
|
||||
def wrapper_get_node_info(node, node_info_id, timeout_s=20.0):
|
||||
return node.get_node_info(
|
||||
node_info_id=node_info_id,
|
||||
timeout_s=timeout_s,
|
||||
)
|
||||
|
||||
|
||||
def wrapper_get_available_configs(node, timeout_s=20.0):
|
||||
return node.get_available_configs(
|
||||
timeout_s=timeout_s,
|
||||
)
|
||||
|
||||
18
src/steps/wrappers_setup.py
Normal file
18
src/steps/wrappers_setup.py
Normal file
@ -0,0 +1,18 @@
|
||||
class NodeStub:
|
||||
def send_message(self, message, timeout_s=20.0):
|
||||
self.message = message
|
||||
self.timeout_s = timeout_s
|
||||
return Ok(1)
|
||||
|
||||
def get_available_node_info_ids(self, timeout_s=20.0):
|
||||
self.timeout_s = timeout_s
|
||||
return Ok(2)
|
||||
|
||||
def get_node_info(self, node_info_id, timeout_s=20.0):
|
||||
self.node_info_id = node_info_id
|
||||
self.timeout_s = timeout_s
|
||||
return Ok(3)
|
||||
|
||||
def get_available_configs(self, timeout_s=20.0):
|
||||
self.timeout_s = timeout_s
|
||||
return Ok(4)
|
||||
35
tests/wrappers_tests/unit_test.py
Normal file
35
tests/wrappers_tests/unit_test.py
Normal file
@ -0,0 +1,35 @@
|
||||
import inspect
|
||||
import pytest
|
||||
from result import Ok
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from src.steps.wrappers_setup import NodeStub
|
||||
from src.node import wrappers_manager
|
||||
|
||||
# from wrapper_setup import NodeWrapper
|
||||
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
|
||||
class TestWrappersManager:
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def wrapper_setup(self):
|
||||
logger.debug(f"Running setup")
|
||||
self.node = NodeForTest()
|
||||
|
||||
def test_wrapper_send_message(self):
|
||||
message = {
|
||||
"contentTopic": "/test/1/chat/proto",
|
||||
"payload": "SGVsbG8=",
|
||||
"ephemeral": False,
|
||||
}
|
||||
|
||||
result = wrappers_manager.wrapper_send_message(self.node, message, timeout_s=5.0)
|
||||
|
||||
assert result == Ok(1)
|
||||
assert self.node.last_message == message
|
||||
assert self.node.last_timeout == 5.0
|
||||
|
||||
def test_wrapper_get_available_node_info_ids(self):
|
||||
result = wrappers_manager.wrapper_get_available_node_info_ids(self.node, timeout_s=6.0)
|
||||
|
||||
assert result == Ok(2)
|
||||
Loading…
x
Reference in New Issue
Block a user