# test_page.tavern.yaml
---
test_name: Obj Standard Properties

includes:
  - !include config.yaml

paho-mqtt:
  client:
    transport: tcp
    client_id: tavern-tester
  connect:
    host: "{host}"
    port: !int "{port:d}"
    timeout: 3
  auth:
    username: "{username}"
    password: "{password}"

stages:
  - name: step 1 - Page test
    mqtt_publish:
      topic: hasp/{plate}/command/page
      payload: "1"
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "1"
      timeout: 1
    delay_after: 0
  - name: step 2 - Page test
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "page 2"
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "2"
      timeout: 1
    delay_after: 0
  - name: step 3 - Page test
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "page=3"
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "3"
      timeout: 1
    delay_after: 0
  - name: step 4 - Page test
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["page=1"]'
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "1"
      timeout: 1
    delay_after: 0
  - name: step 5 - Page test
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["page 300"]'
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "1"
      timeout: 1
    delay_after: 0

---
test_name: Reboot Command

includes:
  - !include config.yaml

paho-mqtt:
  client:
    transport: tcp
    client_id: tavern-tester
  connect:
    host: "{host}"
    port: !int "{port:d}"
    timeout: 3
  auth:
    username: "{username}"
    password: "{password}"

stages:
  - name: Test reboot command
    mqtt_publish:
      topic: hasp/{plate}/command/reboot
      payload: ""
    mqtt_response:
      topic: hasp/{plate}/LWT
      payload: "offline"
      timeout: 20
    delay_after: 0

---
test_name: Idle States

includes:
  - !include config.yaml

paho-mqtt:
  client:
    transport: tcp
    client_id: tavern-tester
  connect:
    host: "{host}"
    port: !int "{port:d}"
    timeout: 3
  auth:
    username: "{username}"
    password: "{password}"

stages:
  - name: Test idle
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "wakeup"
    mqtt_response:
      topic: hasp/{plate}/state/idle
      payload: "long"
      timeout: 255
    delay_after: 0

  - name: Test idle
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "wakeup"
    mqtt_response:
      topic: hasp/{plate}/state/idle
      payload: "short"
      timeout: 128
    delay_after: 0

  - name: Test idle
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "wakeup"
    mqtt_response:
      topic: hasp/{plate}/state/idle
      payload: "off"
      timeout: 1
    delay_after: 0
