Turn entities in properties into entity ids
(data)
| 17 | |
| 18 | |
| 19 | def _normalize_data(data): |
| 20 | """Turn entities in properties into entity ids""" |
| 21 | entities = data["layout"]["entities"] |
| 22 | for obj in entities: |
| 23 | schema = model.get(obj.get("schema")) |
| 24 | if schema is None: |
| 25 | raise InvalidData("Invalid schema %s" % obj.get("schema")) |
| 26 | properties = obj.get("properties", {}) |
| 27 | for name, values in list(properties.items()): |
| 28 | prop = schema.get(name) |
| 29 | if prop.type == registry.entity: |
| 30 | properties[prop.name] = [] |
| 31 | for value in ensure_list(values): |
| 32 | entity_id = get_entity_id(value) |
| 33 | properties[prop.name].append(entity_id) |
| 34 | return data |
| 35 | |
| 36 | |
| 37 | class EntitySetAPITest(TestCase): |