Пример #1
0
def test_upload(tmpdir):
    path = str(tmpdir.join('simple.segy'))
    # random number assures random guid
    create_random(path)

    guid = upload(path)
    client = simple.simple_client(SERVER_URL)
    res = client.sliceByIndex(guid, dim=0, index=0)().numpy()
    np.testing.assert_array_equal(res[0], np.array([1.25, 1.5]))
Пример #2
0
def test_slice(cube_guid):
    client = simple.simple_client(SERVER_URL)
    res_lineno = client.sliceByLineno(cube_guid, dim=0, lineno=2)().numpy()
    res_index = client.sliceByIndex(cube_guid, dim=0, index=1)().numpy()

    assert len(res_lineno) == 2
    np.testing.assert_array_equal(res_lineno[0], np.array([106, 107, 108]))
    np.testing.assert_array_equal(res_lineno[1], np.array([109, 110, 111]))
    np.testing.assert_array_equal(res_lineno, res_index)
Пример #3
0
def test_curtain(cube_guid):
    client = simple.simple_client(SERVER_URL)
    res_lineno = client.curtainByLineno(cube_guid,
                                        [[3, 11], [1, 10], [2, 11]])().numpy()
    res_index = client.curtainByIndex(cube_guid,
                                      [[2, 1], [0, 0], [1, 1]])().numpy()

    assert len(res_lineno) == 3
    np.testing.assert_array_equal(res_lineno[0], np.array([100, 101, 102]))
    np.testing.assert_array_equal(res_lineno[1], np.array([109, 110, 111]))
    np.testing.assert_array_equal(res_lineno[2], np.array([115, 116, 117]))
    np.testing.assert_array_equal(res_lineno, res_index)
Пример #4
0
def test_upload(tmpdir):
    path = str(tmpdir.join('simple.segy'))
    # random number assures random guid
    data = np.array(
        [[1.25, 1.5], [random.uniform(2.5, 2.75),
                       random.uniform(2.75, 3)]],
        dtype=np.float32)
    segyio.tools.from_array(path, data)

    guid = upload(path)
    client = simple.simple_client(SERVER_URL)
    res = client.sliceByIndex(guid, dim=0, index=0)().numpy()
    np.testing.assert_array_equal(res[0], np.array([1.25, 1.5]))
Пример #5
0
def test_azure_flow(tmpdir, azure_upload):
    path = str(tmpdir.join('upload.segy'))
    data = np.array(
        [[1.75, 1.5], [random.uniform(2.5, 2.75),
                       random.uniform(2.75, 3)]],
        dtype=np.float32)

    scan_meta = azure_upload(path, data)
    upload_token = sign_azure_request()
    upload(path,
           storage_location=STORAGE_LOCATION + "?" + upload_token,
           scan_meta=scan_meta)

    guid = scan_meta["guid"]
    client = simple.simple_client(SERVER_URL)
    token = sign_azure_request(container_name=guid)
    res = client.sliceByIndex(guid, dim=0, index=0)(sas=token).numpy()
    np.testing.assert_array_equal(res, data)
Пример #6
0
def test_upload_fails_with_bad_credentials(token, tmpdir):
    """ Tests that cloud resources can't be accessed without good credentials
    Details are considered to be covered by azure itself, as well as any incorrect
    parameters users might provide (e.g. insufficient permissions)
    """
    path = str(tmpdir.join('noupload.segy'))
    data = np.array(
        [[1.25, 1.5], [random.uniform(2.5, 2.75),
                       random.uniform(2.75, 3)]],
        dtype=np.float32)
    segyio.tools.from_array(path, data)

    with pytest.raises(Exception) as exc:
        upload(path, storage_location=STORAGE_LOCATION + "?" + token)
    assert "Server failed to authenticate the request" in str(exc.value.stderr)

    client = simple.simple_client(SERVER_URL)
    with pytest.raises(Exception) as exc:
        client.sliceByIndex("whicheverguid", dim=0, index=0)(sas=token).numpy()
    assert "Unauthorized" in str(exc)