def test_crs(crs, expected):
    metadata = {
        'bounds': sampleBounds(),
        'nativeBounds': {},
        'type_': 'raster'
    }
    metadata['crs'] = crs
    schema = BaseSchema()
    meta = schema.load(metadata)
    assert meta['crs'] == expected
def create_geometa(girder_item, girder_file, metadata=None):
    if not metadata:
        metadata = get_geometa(girder_item, girder_file)

    if metadata:
        schema = BaseSchema()
        schema.load(metadata)
        girder_item['geometa'] = metadata
        Item().save(girder_item)
        Item().collection.create_index([(GEOSPATIAL_FIELD, "2dsphere")])

    return girder_item
Exemple #3
0
def upload_handler(event):
    _id = event.info['file']['_id']
    girder_file = File().load(_id, force=True)
    girder_item = Item().load(event.info['file']['itemId'], force=True)
    path = _get_girder_path(girder_file)
    for entry_point_name, entry_point in get_handlers().items():
        try:
            metadata = entry_point(path)
            schema = BaseSchema()
            schema.load(metadata)
            girder_item['geometa'] = metadata
            Item().save(girder_item)
        except CannotHandleError:
            pass
def test_bad_bounds(bounds):
    metadata = {'crs': '', 'nativeBounds': {}}
    metadata['bounds'] = bounds
    schema = BaseSchema()
    with pytest.raises(ValidationError):
        schema.load(metadata)
def test_bad_type(type_):
    metadata = {'bounds': sampleBounds(), 'nativeBounds': {}, 'crs': ''}
    metadata['type_'] = type_
    schema = BaseSchema()
    with pytest.raises(ValidationError):
        schema.load(metadata)
def test_bad_native_bounds(nativeBounds):
    metadata = {'bounds': sampleBounds(), 'type_': 'raster', 'crs': ''}
    metadata['nativeBounds'] = nativeBounds
    schema = BaseSchema()
    with pytest.raises(ValidationError):
        schema.load(metadata)
def test_schema_with_missing_variables(metadata):
    schema = BaseSchema()
    with pytest.raises(ValidationError):
        schema.load(metadata)