def test_mk_fields_from(): fields_name_error = [{}] fields_valid = [{ "name": "flight_id", "type": "INTEGER", "description": "flight id", "tags": ["tag1", "tag2"] }, { "name": "flight_name", "type": "VARCHAR", "description": "flight name", "tags": ["tag3", "tag4"] }, { "name": "flight_date", "type": "TIMESTAMP", "description": "flight date" }] new_fields_valid = [{ "name": "flight_id", "type": "INTEGER", "description": "flight id", "tags": ["tag1", "tag2"] }, { "name": "flight_name", "type": "VARCHAR", "description": "flight name", "tags": ["tag3", "tag4"] }, { "name": "flight_date", "type": "TIMESTAMP", "description": "flight date" }] assert Utils.mk_fields_from(fields=fields_valid) == new_fields_valid with pytest.raises(ValueError): Utils.mk_fields_from(fields=fields_name_error)
def create_dataset(self, namespace_name, dataset_name, dataset_type, physical_name, source_name, description=None, run_id=None, schema_location=None, fields=None, tags=None): Utils.check_name_length(namespace_name, 'namespace_name') Utils.check_name_length(dataset_name, 'dataset_name') Utils.is_instance_of(dataset_type, DatasetType) if dataset_type == DatasetType.STREAM: MarquezClient._is_none(schema_location, 'schema_location') Utils.check_name_length(physical_name, 'physical_name') Utils.check_name_length(source_name, 'source_name') payload = { 'type': dataset_type.value, 'physicalName': physical_name, 'sourceName': source_name, } if description: payload['description'] = description if run_id: payload['runId'] = run_id if fields: payload['fields'] = Utils.mk_fields_from(fields) if tags: payload['tags'] = tags if schema_location: payload['schemaLocation'] = schema_location return self._put(self._url('/namespaces/{0}/datasets/{1}', namespace_name, dataset_name), payload=payload)