Source

htsql / test / input / format.yaml

Full commit
#
# Copyright (c) 2006-2012, Prometheus Research, LLC
#

title: Formatting Output Data
id: format
tests:

- title: Supported Output Formats
  tests:
  - uri: /school/:raw
  - uri: /school/:json
  - uri: /school/:csv
  - uri: /school/:tsv
  - uri: /school/:xml
  - uri: /school/:html
  - uri: /school/:txt
  - uri: /school/:unknown
    expect: 400

- title: Format Selection by `Accept`
  tests:
  - uri: /school
    headers:
      Accept: x-htsql/raw
  - uri: /school
    headers:
      Accept: application/json
  - uri: /school
    headers:
      Accept: text/csv
  - uri: /school
    headers:
      Accept: text/tab-separated-values
  - uri: /school
    headers:
      Accept: application/xml
  - uri: /school
    headers:
      Accept: text/html
  - uri: /school
    headers:
      Accept: text/plain
  # Empty segment
  - uri: /
    headers:
      Accept: x-htsql/raw
  - uri: /
    headers:
      Accept: application/json
  - uri: /
    headers:
      Accept: text/csv
  - uri: /
    headers:
      Accept: application/xml
  - uri: /
    headers:
      Accept: text/html
  - uri: /
    headers:
      Accept: text/plain

- title: The `AS` Decorator
  tests:
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:raw
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:json
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:csv
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:tsv
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:xml
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:html
    - uri: /(school :as 'List of Schools')
            {name :as Name, count(department) :as '# of Departments'}
            /:txt

- title: Data Types
  tests:
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:raw
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:json
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:csv
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:tsv
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:xml
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:html
  - uri: /{null(), true(), false(), 60, 2.125, 271828e-5, 'HTSQL',
           date('2010-04-15'), time('20:13:04.5'), datetime('2010-04-15 20:13')}
          /:txt

- title: Identity
  tests:
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:raw
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:json
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:csv
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:tsv
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:xml
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:html
  - uri: /enrollment[1010.((mth.101).(2008.fall).001)]{id()}
         /:txt

- title: No Rows
  tests:
  - uri: /school?false()/:raw
  - uri: /school?false()/:json
  - uri: /school?false()/:csv
  - uri: /school?false()/:tsv
  - uri: /school?false()/:xml
  - uri: /school?false()/:html
  - uri: /school?false()/:txt

- title: Empty Selector
  tests:
  - uri: /{}/:raw
  - uri: /{}/:json
  - uri: /{}/:csv
  - uri: /{}/:tsv
  - uri: /{}/:xml
  - uri: /{}/:html
  - uri: /{}/:txt
  - uri: /school{}?campus='old'/:raw
  - uri: /school{}?campus='old'/:json
  - uri: /school{}?campus='old'/:csv
  - uri: /school{}?campus='old'/:tsv
  - uri: /school{}?campus='old'/:xml
  - uri: /school{}?campus='old'/:html
  - uri: /school{}?campus='old'/:txt
  - uri: /department{name, school{}}?!school|school.campus='north'/:raw
  - uri: /department{name, school{}}?!school|school.campus='north'/:json
  - uri: /department{name, school{}}?!school|school.campus='north'/:csv
  - uri: /department{name, school{}}?!school|school.campus='north'/:tsv
  - uri: /department{name, school{}}?!school|school.campus='north'/:xml
  - uri: /department{name, school{}}?!school|school.campus='north'/:html
  - uri: /department{name, school{}}?!school|school.campus='north'/:txt

- title: Special Characters
  tests:
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:raw
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:json
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:csv
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:tsv
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:xml
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:html
  - uri: /{'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10',
           '%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F',
           '%CE%BE', '\/%25''"&<>#', ''}/:txt

- title: Nested Segments
  tests:
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:raw
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:json
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:csv
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:tsv
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:xml
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:html
  - uri: /{/null, /school.limit(3), /department.limit(5)}/:txt
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:raw
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:json
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:csv
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:tsv
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:xml
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:html
  - uri: /school?code={'edu','mus','sc'}
                {name, /program{degree, title},
                 /department{name, /course{no, title}}}/:txt
  - uri: /(/(/(/(/true))))/:raw
  - uri: /(/(/(/(/true))))/:json
  - uri: /(/(/(/(/true))))/:csv
  - uri: /(/(/(/(/true))))/:tsv
  - uri: /(/(/(/(/true))))/:xml
  - uri: /(/(/(/(/true))))/:html
  - uri: /(/(/(/(/true))))/:txt

- title: Commands
  tests:
  - uri: /school/:retrieve
  - uri: /retrieve(/school)
  - uri: /school/:retrieve/:raw
  - uri: /school/:sql
  - uri: /school/:retrieve/:sql
  # Errors
  - uri: /retrieve()
    expect: 400
  - uri: /retrieve(school)
    expect: 400
  - uri: /school/:html/:retrieve
    expect: 400
  - uri: /school/:html/:json
    expect: 400
  - uri: /school/:html/:sql
    expect: 400