1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
import paho.mqtt.client as client
import pytest
class Test_client_function:
"""
Tests on topic_matches_sub function in the client module
"""
@pytest.mark.parametrize("sub,topic", [
("foo/bar", "foo/bar"),
("foo/+", "foo/bar"),
("foo/+/baz", "foo/bar/baz"),
("foo/+/#", "foo/bar/baz"),
("A/B/+/#", "A/B/B/C"),
("#", "foo/bar/baz"),
("#", "/foo/bar"),
("/#", "/foo/bar"),
("$SYS/bar", "$SYS/bar"),
])
def test_matching(self, sub, topic):
assert client.topic_matches_sub(sub, topic)
@pytest.mark.parametrize("sub,topic", [
("test/6/#", "test/3"),
("foo/bar", "foo"),
("foo/+", "foo/bar/baz"),
("foo/+/baz", "foo/bar/bar"),
("foo/+/#", "fo2/bar/baz"),
("/#", "foo/bar"),
("#", "$SYS/bar"),
("$BOB/bar", "$SYS/bar"),
])
def test_not_matching(self, sub, topic):
assert not client.topic_matches_sub(sub, topic)
|