play-mqtt

pytest-play support for MQTT


Keywords
play_mqtt, mqtt, pytest, python, testing
License
Apache-2.0
Install
pip install play-mqtt==0.0.5

Documentation

play mqtt

https://travis-ci.org/davidemoro/play_mqtt.svg?branch=develop Documentation Status

pytest-play support for MQTT support.

Thanks to play_mqtt you can test the integration between a mocked IoT device that sends commands on MQTT and a reactive web application with UI checks.

You can also build a simulator that generates messages for you.

More info and examples on:

Features

This project defines a new pytest-play command:

- provider: mqtt
  type: publish
  host: "$mqtt_host"
  port: $mqtt_port
  endpoint: "$mqtt_endpoint"
  payload: '{
    "endpoint": "$mqtt_endpoint",
    "payload": {
      "obj_id_L": [0],
      "bin_value": [77251432],
      "measure_id": [100],
      "measureType": ["float"],
      "start_time": 1514911926114
    },
    "host": "$mqtt_host",
    "provider": "mqtt",
    "type": "publish",
    "port": "$mqtt_port"}'

Subscribe command:

test_data:
  - data: ciao1
---
- provider: mqtt
  type: subscribe
  host: iot.eclipse.org
  port: 1883
  topic: "home/bedroom/light"
  name: "messages"
- provider: mqtt
  type: publish
  host: iot.eclipse.org
  port: 1883
  endpoint: "home/bedroom/light"
  payload: $data
- provider: python
  type: wait_until
  timeout: 6
  expression: 'len(variables["messages"]) == 1'
  poll: 0.1
  sub_commands: []
- provider: python
  type: assert
  expression: 'len(variables["messages"]) == 1'
- provider: python
  type: assert
  expression: 'variables["messages"][0] == "$data"'

Twitter

pytest-play tweets happens here:

Credits

This package was created with Cookiecutter and the cookiecutter-play-plugin (based on audreyr/cookiecutter-pypackage project template).