Ejemplo n.º 1
0
    def create_dataset(self,
                       namespace_name,
                       dataset_name,
                       dataset_type,
                       dataset_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:
            Utils.is_none(schema_location, 'schema_location')

        Utils.check_name_length(dataset_physical_name, 'dataset_physical_name')
        Utils.check_name_length(source_name, 'source_name')

        payload = {
            'type': dataset_type.value,
            'physicalName': dataset_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)
Ejemplo n.º 2
0
def test_is_none():
    with pytest.raises(ValueError):
        Utils.is_none(None, None)