예제 #1
0
    def _on_frame(self, topic, payload):
        cb = None
        # Search if topic has a registered callback
        if topic in self.callbacks:
            cb = self.callbacks[topic]
        # else pick default callback
        else:
            cb = self.default_callback

        # Extract eventual indexing and grouping data from topic
        topic, opts = translate(topic)

        # check callback is valid and call
        if cb:
            cb(topic,payload, opts)
예제 #2
0
    def _on_frame(self, topic, payload):
        cb = None
        # Search if topic has a registered callback
        if topic in self.callbacks:
            cb = self.callbacks[topic]
        # else pick default callback
        else:
            cb = self.default_callback

        # Extract eventual indexing and grouping data from topic
        topic, opts = translate(topic)

        # check callback is valid and call
        if cb:
            cb(topic, payload, opts)
예제 #3
0
def test_translate_simple_index():
    topic = "sometopic:0"
    top, opts = translate(topic)
    assert top == "sometopic"
    assert type(opts) == dict
    assert opts['index'] == 0
예제 #4
0
def test_translate_pass_thru():
    topic = "sometopic"
    top, opts = translate(topic)
    assert top == topic
    assert opts is None
예제 #5
0
def test_translate_discard():
    topic = "12:sometopic"
    top, opts = translate(topic)
    assert top == "12:sometopic"
    assert opts is None
예제 #6
0
def test_translate_pass_thru():
    topic = "sometopic"
    top, opts = translate(topic)
    assert top == topic
    assert opts is None
예제 #7
0
def test_translate_discard():
    topic = "12:sometopic"
    top, opts = translate(topic)
    assert top == "12:sometopic"
    assert opts is None
예제 #8
0
def test_translate_simple_index():
    topic = "sometopic:0"
    top, opts = translate(topic)
    assert top == "sometopic"
    assert type(opts) == dict
    assert opts['index'] == 0