| Conditions | 6 |
| Total Lines | 14 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import random |
||
| 21 | def schema_to_object_builder(schema, p=1.0): |
||
| 22 | mutation = random.random() |
||
| 23 | root_object = build_one_of_type(schema['type'])() |
||
| 24 | |||
| 25 | if isinstance(root_object, list): |
||
| 26 | if p > mutation: |
||
| 27 | root_object.append(schema_to_object_builder(schema['inner'], p=p)) |
||
| 28 | |||
| 29 | elif isinstance(root_object, dict): |
||
| 30 | for prop in schema['inner']: |
||
| 31 | if p > mutation: |
||
| 32 | root_object[prop['name']] = schema_to_object_builder(prop, p=p) |
||
| 33 | |||
| 34 | return root_object |
||
| 35 |