---
test_name: Check empty queue format (json output)

strict:
  - json:on

stages:
  - name: queue format empty
    request:
      url: "http://{SAB_HOST}:{SAB_PORT}/api"
      method: GET
      params:
        mode: queue
        apikey: "{SAB_APIKEY}"
    response:
      status_code: 200
      headers:
        content-type: !re_match "application/json"
        content-type: !re_search "charset=(UTF|utf)-8"
        pragma: "no-cache"
        access-control-allow-origin: "*"
      json:
        queue:
          version: "{SAB_VERSION}"
          paused: !anybool
          pause_int: !re_match "[0-9]*"
          paused_all: !anybool
          diskspace1: !re_match "[0-9.]*"
          diskspace2: !re_match "[0-9.]*"
          diskspace1_norm: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          diskspace2_norm: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          diskspacetotal1: !re_match "[0-9.]*"
          diskspacetotal2: !re_match "[0-9.]*"
          speedlimit: !re_match "[0-9]*"
          speedlimit_abs: !re_match "[0-9.]*" # Value may be empty if unset so !anyint won't work
          have_warnings: !re_match "[0-9]*"
          finishaction: null
          quota: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          have_quota: !anybool
          left_quota: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          cache_art: !re_search "[0-9]*"
          cache_size: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          kbpersec: !re_match "[0-9.]*"
          speed: !re_search "[0-9][0-9.]*.?(\ [A-Z])?"
          mbleft: !re_match "[0-9.]*"
          mb: !re_match "[0-9.]*"
          sizeleft: "0 B"
          size: "0 B"
          noofslots_total: 0
          status: "Idle"
          timeleft: "0:00:00"
          noofslots: 0
          start: 0
          limit: 0
          finish: 0
          slots: []

---
test_name: Check empty queue format (xml output)

stages:
  - name: queue format empty
    request:
      url: "http://{SAB_HOST}:{SAB_PORT}/api"
      method: GET
      params:
        mode: queue
        apikey: "{SAB_APIKEY}"
        output: xml
    response:
      status_code: 200
      headers:
        content-type: !re_match "text/xml"
        content-type: !re_search "charset=(UTF|utf)-8"
        pragma: "no-cache"
        access-control-allow-origin: "*"
        content-length: !re_match "[0-9]+"
      verify_response_with:
        function: tavalidate:assert_xml
        extra_kwargs:
          strict: True # don't accept extra tags in the response
          expected: |
            <?xml version="1.0" encoding="UTF-8" ?>
            <queue><version>!anystr</version>
            <paused>!anybool</paused>
            <pause_int>!anyint</pause_int>
            <paused_all>!anybool</paused_all>
            <diskspace1>!anyfloat</diskspace1>
            <diskspace2>!anyfloat</diskspace2>
            <diskspace1_norm>!anystr</diskspace1_norm>
            <diskspace2_norm>!anystr</diskspace2_norm>
            <diskspacetotal1>!anyfloat</diskspacetotal1>
            <diskspacetotal2>!anyfloat</diskspacetotal2>
            <speedlimit>!anyint</speedlimit>
            <speedlimit_abs>!anystr</speedlimit_abs>
            <have_warnings>!anyint</have_warnings>
            <finishaction>!anything</finishaction>
            <quota>!anystr</quota>
            <have_quota>!anybool</have_quota>
            <left_quota>!anystr</left_quota>
            <cache_art>0</cache_art>
            <cache_size>0 B</cache_size>
            <kbpersec>!anyfloat</kbpersec>
            <speed>0 </speed>
            <mbleft>0.00</mbleft>
            <mb>0.00</mb>
            <sizeleft>0 B</sizeleft>
            <size>0 B</size>
            <noofslots_total>0</noofslots_total>
            <status>Idle</status>
            <timeleft>0:00:00</timeleft>
            <noofslots>0</noofslots>
            <start>0</start>
            <limit>0</limit>
            <finish>0</finish>
            <slots></slots>
            </queue>
