# test_value_str.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: Page 1
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "page 1"
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "1"
      timeout: 1

---
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}"

marks:
  - parametrize:
      key:
        - color
        - hex
        - r
        - g
        - b
        - rgb565
      vals:
        - ["red", "#ff0000", 255, 0, 0, 63488]
        - ["tan", "#d5b68b", 213, 182, 139, 54705]
        - ["aqua", "#00ffff", 0, 255, 255, 2047]
        - ["blue", "#0000ff", 0, 0, 255, 31]
        - ["cyan", "#00ffff", 0, 255, 255, 2047]
        - ["gold", "#ffd600", 255, 214, 0, 65184]
        - ["gray", "#838183", 131, 129, 131, 33808]
        - ["grey", "#838183", 131, 129, 131, 33808]
        - ["lime", "#00ff00", 0, 255, 0, 2016]
        - ["navy", "#000083", 0, 0, 131, 16]
        - ["peru", "#cd8539", 205, 133, 57, 52263]
        - ["pink", "#ffc2cd", 255, 194, 205, 65049]
        - ["plum", "#dea1de", 222, 161, 222, 56603]
        - ["snow", "#fffaff", 255, 250, 255, 65503]
        - ["teal", "#008183", 0, 129, 131, 1040]
        - ["azure", "#f6ffff", 246, 255, 255, 63487]
        - ["beige", "#f6f6de", 246, 246, 222, 63419]
        - ["black", "#000000", 0, 0, 0, 0]
        - ["blush", "#b50000", 181, 0, 0, 45056]
        - ["brown", "#a42829", 164, 40, 41, 41285]
        - ["coral", "#ff7d52", 255, 125, 82, 64490]
        - ["green", "#008100", 0, 129, 0, 1024]
        - ["ivory", "#fffff6", 255, 255, 246, 65534]
        - ["khaki", "#f6e68b", 246, 230, 139, 63281]
        - ["linen", "#fff2e6", 255, 242, 230, 65436]
        - ["olive", "#838100", 131, 129, 0, 33792]
        - ["wheat", "#f6deb5", 246, 222, 181, 63222]
        - ["white", "#ffffff", 255, 255, 255, 65535]
        - ["bisque", "#ffe6c5", 255, 230, 197, 65336]
        - ["indigo", "#4a0083", 74, 0, 131, 18448]
        - ["maroon", "#830000", 131, 0, 0, 32768]
        - ["orange", "#ffa500", 255, 165, 0, 64800]
        - ["orchid", "#de71d5", 222, 113, 213, 56218]
        - ["purple", "#830083", 131, 0, 131, 32784]
        - ["salmon", "#ff8173", 255, 129, 115, 64526]
        - ["sienna", "#a45029", 164, 80, 41, 41605]
        - ["tomato", "#ff6141", 255, 97, 65, 64264]
        - ["violet", "#ee81ee", 238, 129, 238, 60445]
        - ["yellow", "#ffff00", 255, 255, 0, 65504]
        - ["fuchsia", "#ff00ff", 255, 0, 255, 63519]
        - ["magenta", "#ff00ff", 255, 0, 255, 63519]
        - ["silver", "#c5c2c5", 197, 194, 197, 50712]

  - parametrize:
      key: obj
      vals:
        - checkbox
        - btn

stages:
  - name: Set bg_color
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p[1].b[0].bg_color={color}"

  - name: Clear page
    mqtt_publish:
      topic: hasp/{plate}/command/clearpage
      payload: ""

  - name: Create object
    mqtt_publish:
      topic: hasp/{plate}/command/jsonl
      json:
        obj: "{obj}"
        id: 1
        text: "{color}"

  - name: Set bg_color
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p[1].b[0].bg_color={rgb565}"

  - name: Test named COLOR
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p[1].b[1].text_color={color}","p[1].b[1].text_color"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        text_color: "{hex}"
        r: !int "{r:d}"
        g: !int "{g:d}"
        b: !int "{b:d}"
      timeout: 1

  - name: Reset
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p[1].b[1].text_color=123"

  - name: Test hex COLOR
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p[1].b[1].text_color={hex}","p[1].b[1].text_color"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        text_color: "{hex}"
        r: !int "{r:d}"
        g: !int "{g:d}"
        b: !int "{b:d}"
      timeout: 1

  - name: Reset
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p[1].b[1].text_color=529"

  - name: Test rgb565 COLOR
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p[1].b[1].text_color={rgb565}","p[1].b[1].text_color"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        text_color: "{hex}"
        r: !int "{r:d}"
        g: !int "{g:d}"
        b: !int "{b:d}"
      timeout: 1
