Exemplo n.º 1
0
 def test_access_with_list(self):
     datalink = DatalinkResults.from_result_url('http://example.com/proc')
     res = [_debytify(r["access_url"])
         for r in datalink.bysemantics(["#this", "#preview-image"])]
     assert len(res)==2
     assert res[0].endswith("eq010000ms/20100927.comb_avg.0001.fits.fz")
     assert res[1].endswith("20100927.comb_avg.0001.fits.fz?preview=True")
Exemplo n.º 2
0
 def test_access_with_expansion(self):
     datalink = DatalinkResults.from_result_url('http://example.com/proc')
     res = [_debytify(r["access_url"])
         for r in datalink.bysemantics(["#this", "#preview"])]
     assert len(res)==3
     assert res[0].endswith("eq010000ms/20100927.comb_avg.0001.fits.fz")
     assert res[1].endswith("20100927.comb_avg.0001.fits.fz?preview=True")
     assert res[2].endswith("http://dc.zah.uni-heidelberg.de/wider.dat")
Exemplo n.º 3
0
def test_find_param_by_keyword():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_lower = find_param_by_keyword('polygon', input_params)
    polygon_upper = find_param_by_keyword('POLYGON', input_params)

    circle_lower = find_param_by_keyword('circle', input_params)
    circle_upper = find_param_by_keyword('CIRCLE', input_params)

    assert polygon_lower == polygon_upper
    assert circle_lower == circle_upper
Exemplo n.º 4
0
def test_find_param_by_keyword():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_lower = find_param_by_keyword('polygon', input_params)
    polygon_upper = find_param_by_keyword('POLYGON', input_params)

    circle_lower = find_param_by_keyword('circle', input_params)
    circle_upper = find_param_by_keyword('CIRCLE', input_params)

    assert polygon_lower == polygon_upper
    assert circle_lower == circle_upper
Exemplo n.º 5
0
def test_serialize_exceptions():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_conv = get_converter(find_param_by_keyword('polygon',
                                                       input_params))
    circle_conv = get_converter(find_param_by_keyword('circle', input_params))
    band_conv = get_converter(find_param_by_keyword('band', input_params))

    with pytest.raises(DALServiceError):
        polygon_conv.serialize((1, 2, 3, 4))

    with pytest.raises(DALServiceError):
        circle_conv.serialize((1, 2, 3, 4))

    with pytest.raises(DALServiceError):
        band_conv.serialize((1, 2, 3))
Exemplo n.º 6
0
def test_serialize():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_conv = get_converter(find_param_by_keyword('polygon',
                                                       input_params))
    circle_conv = get_converter(find_param_by_keyword('circle', input_params))
    scale_conv = get_converter(find_param_by_keyword('scale', input_params))
    kind_conv = get_converter(find_param_by_keyword('kind', input_params))

    assert polygon_conv.serialize((1, 2, 3)) == "1 2 3"
    assert polygon_conv.serialize(np.array((1, 2, 3))) == "1 2 3"

    assert circle_conv.serialize((1.1, 2.2, 3.3)) == "1.1 2.2 3.3"
    assert circle_conv.serialize(np.array((1.1, 2.2, 3.3))) == "1.1 2.2 3.3"

    assert scale_conv.serialize(1) == "1"
    assert kind_conv.serialize("DATA") == "DATA"
Exemplo n.º 7
0
def test_serialize_exceptions():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_conv = get_converter(
        find_param_by_keyword('polygon', input_params))
    circle_conv = get_converter(
        find_param_by_keyword('circle', input_params))
    band_conv = get_converter(
        find_param_by_keyword('band', input_params))

    with pytest.raises(DALServiceError):
        polygon_conv.serialize((1, 2, 3, 4))

    with pytest.raises(DALServiceError):
        circle_conv.serialize((1, 2, 3, 4))

    with pytest.raises(DALServiceError):
        band_conv.serialize((1, 2, 3))
Exemplo n.º 8
0
def test_serialize():
    datalink = DatalinkResults.from_result_url('http://example.com/proc')
    proc = datalink[0]
    input_params = {param.name: param for param in proc.input_params}

    polygon_conv = get_converter(
        find_param_by_keyword('polygon', input_params))
    circle_conv = get_converter(
        find_param_by_keyword('circle', input_params))
    scale_conv = get_converter(
        find_param_by_keyword('scale', input_params))
    kind_conv = get_converter(
        find_param_by_keyword('kind', input_params))

    assert polygon_conv.serialize((1, 2, 3)) == "1 2 3"
    assert polygon_conv.serialize(np.array((1, 2, 3))) == "1 2 3"

    assert circle_conv.serialize((1.1, 2.2, 3.3)) == "1.1 2.2 3.3"
    assert circle_conv.serialize(np.array((1.1, 2.2, 3.3))) == "1.1 2.2 3.3"

    assert scale_conv.serialize(1) == "1"
    assert kind_conv.serialize("DATA") == "DATA"
Exemplo n.º 9
0
def test_inf():
    datalink = DatalinkResults.from_result_url('http://example.com/proc_inf')
    proc = datalink[0]

    proc.process(band=(6000, +np.inf) * u.Angstrom)
Exemplo n.º 10
0
def test_units():
    datalink = DatalinkResults.from_result_url('http://example.com/proc_units')
    proc = datalink[0]

    proc.process(band=(6000*u.Angstrom, 80000*u.Angstrom))
Exemplo n.º 11
0
 def test_access_with_string(self):
     datalink = DatalinkResults.from_result_url('http://example.com/proc')
     res = [_debytify(r["access_url"])
         for r in datalink.bysemantics("#this")]
     assert len(res)==1
     assert res[0].endswith("eq010000ms/20100927.comb_avg.0001.fits.fz")
Exemplo n.º 12
0
def test_inf():
    datalink = DatalinkResults.from_result_url('http://example.com/proc_inf')
    proc = datalink[0]

    proc.process(band=(6000, +np.inf) * u.Angstrom)
Exemplo n.º 13
0
def test_units():
    datalink = DatalinkResults.from_result_url('http://example.com/proc_units')
    proc = datalink[0]

    proc.process(band=(6000*u.Angstrom, 80000*u.Angstrom))