Exemplo n.º 1
0
def test_decode_payload_alldata(caplog):

    with caplog.at_level(logging.DEBUG):

        # Bootstrap the core machinery without MQTT.
        core_bootstrap(configfile=configfile_full)

        # Proof that decoding a valid JSON payload decodes it appropriately.
        outcome = decode_payload(section='test/alldata', topic='bar', payload='{"baz": "qux"}')
        assert outcome['topic'] == 'bar'
        assert outcome['baz'] == 'qux'
        assert outcome['alldata-key'] == 'alldata-value'
Exemplo n.º 2
0
def test_decode_payload_foo(caplog):

    with caplog.at_level(logging.DEBUG):

        # Bootstrap the core machinery without MQTT.
        core_bootstrap(configfile=configfile_full)

        # Proof that decoding an unconfigured thing yields nothing sensible.
        outcome = decode_payload(section='foo', topic='bar', payload='baz')
        assert outcome['topic'] == 'bar'
        assert outcome['payload'] == 'baz'
        assert 'Cannot decode JSON object, payload=baz' in caplog.text, caplog.text
Exemplo n.º 3
0
def test_decode_payload_foo(caplog):

    with caplog.at_level(logging.DEBUG):

        # Bootstrap the core machinery without MQTT.
        core_bootstrap(configfile=configfile_full)

        # Proof that decoding an unconfigured thing yields nothing sensible.
        outcome = decode_payload(section="foo", topic="bar", payload="baz")
        assert outcome["topic"] == "bar"
        assert outcome["payload"] == "baz"
        assert "Cannot decode JSON object, payload=baz" in caplog.text, caplog.text
Exemplo n.º 4
0
def test_decode_payload_alldata(caplog):

    with caplog.at_level(logging.DEBUG):

        # Bootstrap the core machinery without MQTT.
        core_bootstrap(configfile=configfile_full)

        # Proof that decoding a valid JSON payload decodes it appropriately.
        outcome = decode_payload(section="test/alldata",
                                 topic="bar",
                                 payload='{"baz": "qux"}')
        assert outcome["topic"] == "bar"
        assert outcome["baz"] == "qux"
        assert outcome["alldata-key"] == "alldata-value"