summaryrefslogtreecommitdiff
path: root/tests/files/success/test_mapping.yaml
blob: 66a08a76738f0782906bc794a7f932a731464fbf (plain)
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
---
name: mapping1
desc: Most basic mapping validation
data:
  foo: bar
schema:
  type: map
  mapping:
    foo:
      type: str
---
name: mapping2
desc: Complex mapping that test several subtypes for each key
#
schema:
  type: map
  required: true
  mapping:
    name:
      type: str
      required: true
    email:
      type: str
      # This pattern value was modified from /@/ to .+@.+ to make it copmatible with python
      pattern: .+@.+
      required: True
    age:
      type: int
    blood:
      type: str
      enum:
        - A
        - B
        - O
        - AB
    birth:
      type: date
data:
  name: foo
  email: foo@mail.com
  age: 20
  blood: AB
  birth: 1985-01-01
---
name: mapping3
desc: Test that mapping works inside a sequence
data:
  - foo: True
schema:
  type: seq
  sequence:
    - type: map
      mapping:
        foo:
          type: bool
---
name: mapping4
desc: Test that map inside seq inside map works
data:
  company: Kuwata lab.
  email: webmaster@kuwata-lab.com
  employees:
    - code: 101
      name: foo
      email: foo@kuwata-lab.com
    - code: 102
      name: bar
      email: bar@kuwata-lab.com
schema:
  type: map
  mapping:
    company:
      type: str
      required: True
    email:
      type: str
    employees:
      type: seq
      sequence:
        - type: map
          mapping:
            code:
              type: int
              required: True
            name:
              type: str
              required: True
            email:
              type: str
---
name: mapping5
desc: test allowempty option to mapping
data:
  datasources:
    test1: test1.py
    test2: test2.py
schema:
  type: map
  mapping:
    datasources:
      type: map
      allowempty: True
      mapping:
        test1:
          type: str
---
name: mapping6
desc: Test that regex keys works
data:
  mic:
    - input
    - foo
  mock:
    - True
    - False
schema:
  type: map
  matching-rule: "any"
  mapping:
    re;(mi.+):
      type: seq
      sequence:
        - type: str
    regex;(mo.+):
      type: seq
      sequence:
        - type: bool
---
name: mapping7
desc: Test that mapping name works
data:
  datasources: test1.py
schema:
  type: map
  mapping:
    datasources:
      type: str
---
name: mapping8
desc: Test that map shortcut works
data:
  datasources: test1.py
schema:
  type: map
  map:
    datasources:
      type: str
---
name: mapping9
desc: Test that you do not have to specify type map
data:
  streams: foobar
schema:
  mapping:
    streams:
      type: str
---
name: mapping10
desc: Test that you do not have to specify type map when map exists in schema
data:
  streams: foobar
schema:
  map:
    streams:
      type: str
---
name: mapping11
desc: Test keyword regex default matching-rule any
data:
  foobar1: 1
  foobar2: 2
  bar2: 3
schema:
  type: map
  mapping:
    regex;([1-2]$):
      type: int
    regex;(^foobar):
      type: int
---
name: mapping12
desc: Test keyword regex declared matching-rule any
data:
  foobar1: 1
  foobar2: 2
  bar2: 3
schema:
  type: map
  matching-rule: 'any'
  mapping:
    regex;([1-2]$):
      type: int
    regex;(^foobar):
      type: int
---
name: mapping13
desc: Test keyword regex declared matching-rule all
data:
  foobar1: 1
  foobar2: 2
  foobar3: 3
schema:
  type: map
  matching-rule: 'all'
  mapping:
    regex;([1-3]$):
      type: int
    regex;(^foobar):
      type: int
---
name: mapping14
desc: Test mixed keyword regex and normal keyword
data:
  standard:
    FRIST-800-53
  AU-1:
    family: AU
    name: Audit and Accountability Policy and Procedures
schema:
  type: map
  mapping:
    regex;([A-Z]-):
      type: map
      mapping:
        name:
          type: str
        family:
          type: str
          required: True
    standard:
      type: str
---
name: mapping-default-1
desc: Test that default mapping keyword works out of the box in a good case
data:
  OWNERSHIP:
    - code: 1
      key: BLM-BURNS
      alias: BLM-BURNS
  WHT: foo
schema:
  type: map
  mapping:
    WHT:
      type: str
    =:
      type: seq
      required: true
      sequence:
        - type: map
          mapping:
            'code':
              type: int
              required: true
              unique: true
            'key':
              type: str
              required: true
            'alias':
              type: str
              required: true
---
name: mapping-default-2
desc: default value of map with number type and no other key matching
#
schema:
  type: map
  mapping:
    =:
      type: number
      range: 
        min: -10
        max: 10
#
data:
  value1: 0
  value2: 10
  value3: -10
---
name: mapping17
desc: Test that allowempty works without specifying mapping keyword when used inside a sequence block
data:
  rally:
    plugins:
      - netcreate-boot: rally/rally-plugins/netcreate-boot 
schema:
  type: map
  mapping:
    rally:
      type: map
      allowempty: True
      mapping:
        plugins:
          type: seq
          sequence:
            - type: map
              allowempty: True
---
name: mapping18
desc: Test that regexes can be 'required'
data:
  person1: Jack
  person2: Fred
schema:
  type: map
  mapping:
    regex;(person[1-9]):
      required: True
---
name: mapping19
desc: Test regex mapping with integer keys
data:
  test:
    1: test
    2: test2
schema:
  type: map
  mapping:
    test:
      type: map
      mapping:
        regex;(.+):
          type: str
---
name: mapping 20
desc: Test mapping with integer keys
data:
  test:
    0: test
schema:
  type: map
  mapping:
    test:
      type: map
      mapping:
        0:
          type: str
---
name: mapping21
desc: Test that 'required' integer regex keys are supported.
data:
  1234: Albert
  1235: Tom
schema:
  type: map
  mapping:
    regex;([0-9]+):
      required: True
      type: str