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

strict:
  - json:on

stages:
  - name: history format empty
    request:
      url: http://{SAB_HOST}:{SAB_PORT}/api
      method: GET
      params:
        mode: history
        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:
        history:
          # all four sizes may have a single digit value, so anything beyond that is optional
          total_size: !re_match "[0-9][0-9.]*.?(\ [A-Z])?"
          month_size: !re_match "[0-9][0-9.]*.?(\ [A-Z])?"
          week_size: !re_match "[0-9][0-9.]*.?(\ [A-Z])?"
          day_size: !re_match "[0-9][0-9.]*.?(\ [A-Z])?"
          slots: []
          noofslots: 0
          ppslots: 0
          last_history_update: !anyint
          version: "{SAB_VERSION}"

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

stages:
  - name: history format empty
    request:
      url: http://{SAB_HOST}:{SAB_PORT}/api
      method: GET
      params:
        mode: history
        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" ?>
            <history>
            <total_size>!anystr</total_size>
            <month_size>!anystr</month_size>
            <week_size>!anystr</week_size>
            <day_size>!anystr</day_size>
            <slots></slots>
            <noofslots>0</noofslots>
            <ppslots>0</ppslots>
            <last_history_update>!anyint</last_history_update>
            <version>!anystr</version>
            </history>
