File: test-main.yaml

package info (click to toggle)
kwalify 0.7.2-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,352 kB
  • sloc: ruby: 8,428; xml: 170; makefile: 37; java: 36
file content (415 lines) | stat: -rw-r--r-- 9,407 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
##
## $Rev$
## $Release: 0.7.2 $
## copyright(c) 2005-2010 kuwata-lab all rights reserved.
##
---
- name:  parseOptions1
  desc:  test Main#parseOptions()
  method: parseOptions
  args: [ -hvsmtlEDf, schema.yaml, -a, gemclass-ruby, -Ipath/to/dir, document.yaml, document2.yaml ]
  expected: |
	command: kwalify
	options:
	  - action: gemclass-ruby
	  - debug: true
	  - emacs: true
	  - help: true
	  - linenum: true
	  - meta: true
	  - quiet: true
	  - schema: schema.yaml
	  - tpath: path/to/dir
	  - untabify: true
	  - version: true
	properties:
	filenames:
	  - document.yaml
	  - document2.yaml
##
- name:  parseOptions2
  desc:  -ffilename
  method: parseOptions
  args: [ -lfschema.yaml, -hagenclass-ruby, -I/path/to/dir]
  expected: |
	command: kwalify
	options:
	  - action: genclass-ruby
	  - help: true
	  - linenum: true
	  - schema: schema.yaml
	  - tpath: /path/to/dir
	properties:
	filenames:
##
- name:  parseOptions3
  desc:  "'--help' is equal to '-h'"
  method: parseOptions
  args:  [ --help, document.yaml ]
  expected: |
	command: kwalify
	options:
	  - help: true
	properties:
	  - help: true
	filenames:
	  - document.yaml
##
- name:  parseOptions4
  desc:  "'-E' turns on '-l'"
  method: parseOptions
  args:  [ -E, document.yaml ]
  expected: |
	command: kwalify
	options:
	  - emacs: true
	  - linenum: true
	properties:
	filenames:
	  - document.yaml
##
---
- name:  optionError1
  desc:  invalid command-line option
  method: parseOptions
  args:  [ -hvi ]
  inspect: '*'
  exception*:
    ruby: CommandOptionError
    java: CommandOptionException
  message: "-i: invalid command option."
  error_symbol*:
    ruby: !ruby/sym command_option_invalid
    java: command.option.invalid
##
- name:  optionError2
  desc:  no argument of '-f'
  method: parseOptions
  args:  [ -f ]
  inspect: '*'
  exception*:
    ruby: CommandOptionError
    java: CommandOptionException
  message: "-f: schema filename is required."
  error_symbol*:
    ruby: !ruby/sym command_option_schema_required
    java: command.option.noschema
####
##name:  optionError3
##desc:  invalid property
##method: parseOptions
##args:  [ --foo@var ]
##inspect: '*'
##exception*:
##  ruby: CommandOptionError
##  #java: CommandOptionException
##message: "'--foo@var': invalid property."
##error_symbol*:
##  ruby: !ruby/sym :command_property_invalid
##  #java: command.property.invalid
#

##
- name:  optionError4
  desc:  action required
  method: execute
  args:  [ document.yaml ]
  inspect: '*'
  expected: |
  exception*:
    ruby: CommandOptionError
    java: CommandOptionException
  message: "command-line option '-f' or '-m' required."
  error_symbol*:
    ruby: !ruby/sym :command_option_noschema
    java: command.option.noaction
##
---
- name:  version  	# -v
  desc:  option '-v'
  method: execute
  args:  [ -vt, document.yaml ]
  expected: |
    0.7.2
##
- name:  help		# -h
  desc:  option '-h'
  method: execute
  args:  [ -hD, document.yaml ]
  expected: |
    kwalify - schema validator and data binding tool for YAML and JSON
    ## Usage1: validate yaml document
    kwalify [..options..] -f schema.yaml doc.yaml [doc2.yaml ...]
    ## Usage2: validate schema definition
    kwalify [..options..] -m schema.yaml [schema2.yaml ...]
    ## Usage3: do action
    kwalify [..options..] -a action -f schema.yaml [schema2.yaml ...]
      -h, --help     : help
      -v             : version
      -q             : quiet
      -s             : silent (obsolete, use '-q' instead)
      -f schema.yaml : schema definition file
      -m             : meta-validation mode
      -t             : expand tab characters
      -l             : show linenumber when errored (experimental)
      -E             : show errors in emacs-style (experimental, implies '-l')
      -a action      : action ('genclass-ruby', 'genclass-php', 'genclass-java')
                       (try '-ha genclass-ruby' for details)
      -I path        : template path (for '-a')
      -P             : allow preceding alias
##
- name:  quiet1	# -q
  desc:  option '-q' (valid)
  method: execute
  args:  [ -qf, quiet1.schema, quiet1.document ]
  expected: |
  schema: &quiet1_schema |
    type:   seq
    sequence:
      - type:   str
  document: &quiet1_document |
    - foo
    - bar
    - baz
##
- name:  quiet2	# -s
  desc:  option '-s' (invalid)
  method: execute
  args:  [ -sf, quiet2.schema, quiet2.document ]
  expected: |
    quiet2.document#1: INVALID
      - [/1] '123': not a string.
      - [/2] 'true': not a string.
  schema: &quiet2_schema |
    type:   seq
    sequence:
      - type:   str
  document: &quiet2_document |
    - foo
    - bar
    - baz
    ---
    - foo
    - 123
    - true
##
- name:  silent1	# -s
  desc:  option '-s' (valid)
  method: execute
  args:  [ -sf, silent1.schema, silent1.document ]
  expected: |
  schema: *quiet1_schema
  document: *quiet1_document
##
- name:  silent2	# -s
  desc:  option '-s' (invalid)
  method: execute
  args:  [ -sf, silent2.schema, silent2.document ]
  expected: |
    silent2.document#1: INVALID
      - [/1] '123': not a string.
      - [/2] 'true': not a string.
  schema: *quiet2_schema
  document: *quiet2_document
##
- name:  untabify	# -t
  desc:  option '-t'
  method: execute
  args:  [ -tf, untabify.schema, untabify.document ]
  expected: |
    untabify.document#0: valid.
  schema: |
        type:		seq
        sequence:
          -	type: map
        	mapping:
          	   "key":
        	  	type: text
        	        required:	yes
        	   "value":
        	        type: any
        	       	required:  yes
  document: |
        #
        	- key: foo
        	  value: 123
                - key: bar
          	  value: [a, b, c]
##
- name:  stream
  desc:  stream document
  method: validation
  schema: |
    type:   seq
    sequence:
      - type:   str
  valid: |
     ---
     - foo
     - bar
     - baz
     ---
     - aaa
     - bbb
     - ccc
  valid_out: |
    stream.valid#0: valid.
    stream.valid#1: valid.
  invalid: |
    ---
    - foo
    - 123
    - baz
    ---
    - aaa
    - bbb
    - true
  invalid_out: |
    stream.invalid#0: INVALID
      - (line 3) [/1] '123': not a string.
    stream.invalid#1: INVALID
      - (line 8) [/2] 'true': not a string.
##
- name:  meta1		# -m
  desc:  meta validation (valid)
  method: execute
  args:  [ -m, meta1.schema ]
  schema: &meta1_schema |
    type:   seq
    sequence:
      - type:   str
  document: |
  expected: &meta1_expected |
    meta1.schema#0: valid.
##
- name:  meta2		# -m
  desc:  meta validation (invalid)
  method: execute
  args:  [ -m, meta2.schema ]
  schema: |
    type:   map
    sequence:
      - type:   str
  document: |
  expected: |
    meta2.schema#0: INVALID
      - [/] type 'map' requires 'mapping:'.
      - [/] 'sequence:': not available with mapping.
##
- name:  emacs		# -E
  desc:  show errors in emacs style
  method: execute
  args:  [ -Ef, emacs.schema, emacs.document ]
  schema: |
    type:   seq
    sequence:
      - type:   map
        mapping:
         "key":   { type: str, required: yes }
         "value": { type: any }
  document: |
    - key: one
      value: 1
    - key: 2
      val: two
    - kye: three
      value:
  expected: |
    emacs.document#0: INVALID
    emacs.document:3:3 [/1/key] '2': not a string.
    emacs.document:4:3 [/1/val] key 'val:' is undefined.
    emacs.document:5:3 [/2] key 'key:' is required.
    emacs.document:5:3 [/2/kye] key 'kye:' is undefined.
##
- name:  preceding1		# -P
  desc:  preceding anchor
  method: execute
  args:  [ -Pf, preceding1.schema, preceding1.document ]
  schema: &preceding1_schema |
    type:   map
    mapping:
     "groups": 
        type:   seq
        sequence:
	  - &GROUP
	    type:  map
	    mapping:
	     "name":  { type: str, required: yes }
	     "owner":  *USER
     "users": 
        type:  seq
	sequence:
	  - &USER
	    type:  map
	    mapping:
	     "name":  { type: str, required: yes }
	     "mail":  { type: str }
	     "group": *GROUP
  document: &preceding1_document |
    groups:
      - &WHEEL
        name: wheel
	owner: *root
      - &GUEST
        name: guest
	owner: *root
      - &USERS
        name: users
	owner: *user1
    users:
      - &root
        name: root
	mail: root@localhost
	group: *WHEEL
      - &user1
        name: user1
	mail: user1@localhost
	group: *USERS
  expected: |
    preceding1.document#0: valid.
##
- name:  preceding2		# -P
  desc:  preceding anchor
  method: execute
  args:  [ -lf, preceding2.schema, preceding2.document ]
  schema: *preceding1_schema
  document: *preceding1_document
  exception*:
    ruby:   "Kwalify::SyntaxError"
    #java:  kwalify.YamlSyntaxException
  errormsg*:
    ruby:   "file: preceding2.schema, line 10: *USER: anchor not found."
    #java:  "*USER: anchor not found."
  expected: |
##
---
- name:  empty1
  desc:  ignore first empty document
  method: execute
  args:  [ -f, empty1.schema, empty1.document ]
  schema: |
    type: map
    mapping:
     "name": { type: str }
  document: |
    ---
    name: Foo
  expected: |
    empty1.document#0: valid.

- name:  empty2
  desc:  report 'empty.' when document is empty
  method: execute
  args:  [ -f, empty2.schema, empty2.document ]
  schema: |
    type: map
    mapping:
     "name": { type: str }
  document: |
    ---
    name: Foo
    ---
  expected: |
    empty2.document#0: valid.
    empty2.document#1: empty.