Source

pyyaml-legacy / yaml / tests / testQueryData.yml

Full commit
data:
    title:
        - &manager
          caption: Manager
          position: 0
        - &programmer
          caption: Programmer
          position: 1
          shadow:
             position: 18
        - &editor
          caption: Editor
          position: ~
          shadow:
             position: 3
    people:
        - &mary
          id: mary
          name: Mary McFoo
          number: 333
          title: *programmer
        - &al
          id: al
          name: Al Barson
          number: 555
          title: *manager
    tasks:
        - id: make a list
          duration: 10
          owner: al
          person: *al
        - id: go to store
          duration: 15
          owner: mary
          person: *mary
        - id: buy stuff
          duration: 25
          owner: mary
          person: *mary
          tasks:
            - id: zoom
              owner: *mary
              duration: 22
            - id: fly
              owner: *al
              duration: 33
        - id: drive home
          duration: 20
          owner: mary
          person: *mary
        - id: watch tv
          duration: 20
          owner: al
          person: *al
        - id: cook food
          duration: 60
          owner: al
          person: *al
        - id: eat stuff
          duration: 35
          owner: al
          person: *al
tests:
    - query:
        select:
            - duration
        from: tasks/*
      expected:
        - duration: 10
        - duration: 15
        - duration: 25
        - duration: 20
        - duration: 20
        - duration: 60
        - duration: 35
    - query:
        select:
            - owner
        from: tasks/*
        where:
          id: cook food
      expected:
        - owner: al
    - query:
        select:
            - id
        from: tasks/*
        where:
          duration: 20
          owner: al
      expected:
        - id: watch tv
    - query:
        select:
            - caption
        from: title/*
        where:
          position: ~
      expected:
         - caption: Editor
    - query:
        select:
            - position
            - shadow/position
        from: title/*
        where:
          caption: Editor
      expected:
         - position: ~
           shadow/position: 3
    - query:
        select:
          - id
          - duration
        from: tasks/*
        where:
            owner: mary
        order:
          - duration
      expected:
        - id: go to store
          duration: 15
        - id: drive home
          duration: 20
        - id: buy stuff
          duration: 25
    - query:
        select:
          - id
          - owner
        from: tasks/*
        where: |
          [duration] == 60
      expected:
        - id: cook food
          owner: al
    - query:
        select:
          - id
        from: tasks/*
        where: |
          [duration] <= 20 and [owner] == 'al'
      expected:
        - id: make a list
        - id: watch tv
    - query:
        select:
          - id
        from: tasks/*
        where:
          - [duration] <= 20 
          - [owner] == 'al'
      expected:
        - id: make a list
        - id: watch tv
      ignore: 1
    - query:
        select:
          - id
        from: tasks/*
        where:
          - [duration] <= 20 
          - owner: 'al'
      expected:
        - id: make a list
        - id: watch tv
      ignore: 1
    - query:
        select:
            - id
            - duration
            - person/name
            - person/number
        from: tasks/*
        where:
          id: make a list
      expected:
        - id: make a list
          duration: 10
          person/name: Al Barson
          person/number: 555
    - query:
        select:
            - person/name
            - person/title/caption
        from: tasks/*
        where:
          id: make a list
      expected:
        - person/name: Al Barson
          person/title/caption: Manager
    - query:
        select:
            - id
            - duration
            - person/name
        from: tasks/*
        where:
          - [duration] > 20 
        order:
          - person/name
          - duration
      expected:
        - id: eat stuff
          duration: 35
          person/name: Al Barson
        - id: cook food
          duration: 60
          person/name: Al Barson
        - id: buy stuff
          duration: 25
          person/name: Mary McFoo
      ignore: 1
    - query:
        select:
            - id
            - duration
        from: tasks
        where:
          - [duration] > 20 
        order:
          - person/name
          - duration
      expected:
        - id: eat stuff
          duration: 35
        - id: cook food
          duration: 60
        - id: buy stuff
          duration: 25
      ignore: 1
    - query:
       select:
         - id
       from: //tasks
      expected:
        - id: make a list
        - id: go to store
        - id: buy stuff
        - id: zoom
        - id: fly
        - id: drive home
        - id: watch tv
        - id: cook food
        - id: eat stuff
      ignore: 1