Exemplo n.º 1
0
def test_create_invalidFormat(monkeypatch):
    """Should raise invalid format."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    with pytest.raises(UserWarning):
        s2_ovr.create(sentinel_scene,
                      bands=["04", "03", "02"],
                      img_format="tif")
Exemplo n.º 2
0
def overview(event, context):
    """Handle overview requests."""
    scene = event['scene']
    bands = event.get('bands', None)
    expression = event.get('expression')
    img_format = event.get('format', 'jpeg')
    if bands:
        bands = bands.split(',') if isinstance(bands, str) else bands
    return s2_ovr.create(scene,
                         bands=bands,
                         expression=expression,
                         img_format=img_format)
Exemplo n.º 3
0
def s2_overview_handler(event, context):
    '''
    '''
    logger.info(event)

    try:
        info = event.get('queryStringParameters')
        scene = info.get('scene')
        bands = info.get('bands', ['04', '03', '02'])
        bands = bands.split(',') if isinstance(bands, str) else bands
        img_format = info.get('format', 'jpeg')

        out = s2_ovr.create(scene, bands, img_format)
        return response('OK', 'text/plain', out, True)
    except:
        return response('ERROR', 'application/json',
                        json.dumps({'ErrorMessage': 'Error'}), True)
Exemplo n.º 4
0
def test_create_validexpression(monkeypatch):
    """Should work as expected (read r,g,b bands and create JPEG image)."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    expression = "(b08 - b04) / (b08 + b04)"
    assert s2_ovr.create(sentinel_scene, expression=expression)
Exemplo n.º 5
0
def test_create_npbandexpress(monkeypatch):
    """Should raise."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    with pytest.raises(Exception):
        s2_ovr.create(sentinel_scene)
Exemplo n.º 6
0
def test_create_lessband(monkeypatch):
    """Should raise on not many bands."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    with pytest.raises(Exception):
        s2_ovr.create(sentinel_scene, bands=[4, 2])
Exemplo n.º 7
0
def test_create_validSmall(monkeypatch):
    """Should work as expected (read bands and create 128x128 image)."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    assert s2_ovr.create(sentinel_scene, bands=["04", "03", "02"], ovrSize=128)
Exemplo n.º 8
0
def test_create_validPNG(monkeypatch):
    """Should work as expected (read r,g,b bands and create PNG image)."""
    monkeypatch.setattr(s2_ovr, "SENTINEL_BUCKET", sentinel_bucket)
    assert s2_ovr.create(sentinel_scene,
                         bands=["04", "03", "02"],
                         img_format="png")