# Path: test/settings/mqttkit.py
# PROCESS_DELAY_MQTT = 0.3
# PROCESS_DELAY_HTTP = 0.3
# class TestSettings:
# 
# Path: test/util.py
# def mqtt_json_sensor(topic, data):
#     payload = json.dumps(data)
#     return mqtt_sensor(topic, payload)
# 
# def sleep(secs):
#     # https://gist.github.com/jhorman/891717
#     return deferLater(reactor, secs, lambda: None)


import logging
import pytest
import pytest_twisted
from twisted.internet import threads
from test.settings.mqttkit import settings, influx_sensors, PROCESS_DELAY_MQTT
from test.util import mqtt_json_sensor, sleep
    "soilLeafAlarm3": "0.0",
    "usUnits": "16.0",
    "soilLeafAlarm1": "0.0",
    "leafWet4": "0.0",
    "txBatteryStatus": "0.0",
    "yearET": "4.88",
    "monthRain_cm": "2.94000000074",
    "UV": "0.0",
    "rainRate_cm_per_hour": "0.0",
    "dayET": "0.0",
    "dateTime": "1492467300.0",
    "windDir": "283.55437192",
    "stormRain_cm": "1.72000000043",
    "ET_cm": "0.0",
    "sunset": "1492538940.0",
    "highOutTemp": "38.4",
    "radiation_Wpm2": "0.0"
}


@pytest_twisted.inlineCallbacks
@pytest.mark.mqtt
@pytest.mark.weewx
def test_weewx_mqtt(machinery, create_influxdb, reset_influxdb):
    """
    Publish single reading in JSON format to MQTT broker
    and proof it is stored in the InfluxDB database.
    """

    # Submit a single measurement, without timestamp.

# Path: test/settings/mqttkit.py
# PROCESS_DELAY_MQTT = 0.3
# PROCESS_DELAY_HTTP = 0.3
# class TestSettings:
# 
# Path: test/util.py
# def mqtt_json_sensor(topic, data):
#     payload = json.dumps(data)
#     return mqtt_sensor(topic, payload)
# 
# def sleep(secs):
#     # https://gist.github.com/jhorman/891717
#     return deferLater(reactor, secs, lambda: None)


# Path: test/test_weewx.py
import logging
import pytest
import pytest_twisted
from twisted.internet import threads
from test.settings.mqttkit import settings, influx_sensors, PROCESS_DELAY_MQTT
from test.util import mqtt_json_sensor, sleep

    "soilLeafAlarm3": "0.0",
    "usUnits": "16.0",
    "soilLeafAlarm1": "0.0",
    "leafWet4": "0.0",
    "txBatteryStatus": "0.0",
    "yearET": "4.88",
    "monthRain_cm": "2.94000000074",
    "UV": "0.0",
    "rainRate_cm_per_hour": "0.0",
    "dayET": "0.0",
    "dateTime": "1492467300.0",
    "windDir": "283.55437192",
    "stormRain_cm": "1.72000000043",
    "ET_cm": "0.0",
    "sunset": "1492538940.0",
    "highOutTemp": "38.4",
    "radiation_Wpm2": "0.0"
}


@pytest_twisted.inlineCallbacks
@pytest.mark.mqtt
@pytest.mark.weewx
def test_weewx_mqtt(machinery, create_influxdb, reset_influxdb):
    """
    Publish single reading in JSON format to MQTT broker
    and proof it is stored in the InfluxDB database.
    """

    # Submit a single measurement, without timestamp.

    yield threads.deferToThread(mqtt_json_sensor, settings.mqtt_topic_json, data)