Beispiel #1
0
def test_validate_tid_bad():
    qs = urllib.urlencode({
        'dataset': 'sealevel',
        'variable': 'gauge',
        'plot': 'ts',
        'tidalGaugeId': 'NOTATID',  # bad value
        'period': 'monthly',
    })

    os.environ['QUERY_STRING'] = qs

    with pytest.raises(ValidationError):
        Dataset.parse()
Beispiel #2
0
def test_alt_range_wrapping():
    params = {
        'variable': 'alt',
        'plot': 'ts',
        'period': 'monthly',
        'lat': -12.270,
        'lon': -163.475
    }

    ds = Dataset()
    r = ds.process(params)

    assert 'error' not in r
Beispiel #3
0
def test_land_error():

    params = {
        'variable': 'alt',
        'plot': 'ts',
        'period': 'monthly',
        'lat': -23.,
        'lon': 146.,
    }

    ds = Dataset()

    from ocean.netcdf.extractor import LandError

    with pytest.raises(LandError):
        ds.process(params)
Beispiel #4
0
def test_gauge_ts(report):
    util.clear_cache('SEA')

    params = {
        'variable': 'gauge',
        'plot': 'ts',
        'period': 'monthly',
        'tidalGaugeId': 'IDO70062',
    }

    ds = Dataset()
    r = ds.process(params)

    print r

    assert 'error' not in r
    assert 'tidimg' in r
    assert 'tidtxt' in r
    assert len(r) == 2

    report(params, r['tidimg'])

    fn = util.get_file_from_url(r['tidtxt'])

    assert os.path.exists(fn)

    with open(fn) as f:
        reader = csv.reader(f)

        for i in xrange(3):
            preamble, = reader.next()

            assert preamble.startswith('#')

        headers = reader.next()
        row = reader.next()

        assert len(headers) == len(row)
        assert row == map(str,
                          [2, 1993, 6241, 479, 0.337, 0.961, 0.642, 0.187])
Beispiel #5
0
def test_surface_alt(report):
    util.clear_cache('SEA')

    params = {
        'variable': 'alt',
        'plot': 'map',
        'period': 'monthly',
        'date': datetime.date(2000, 2, 1),
        'area': 'pac',
    }

    ds = Dataset()
    r = ds.process(params)

    print r

    assert 'error' not in r
    assert 'img' in r
    assert 'altimg' not in r

    assert 'alt' in r['img']

    report(params, r['img'])
Beispiel #6
0
def test_validate_tid():
    qs = urllib.urlencode({
        'dataset': 'sealevel',
        'variable': 'gauge',
        'plot': 'ts',
        'tidalGaugeId': 'IDO70062',
        'period': 'monthly',
    })

    os.environ['QUERY_STRING'] = qs

    params = Dataset.parse()

    print params
Beispiel #7
0
def test_rec_ts(report):
    util.clear_cache('SEA')

    params = {
        'variable': 'rec',
        'plot': 'ts',
        'period': 'monthly',
        'lat': -30.,
        'lon': 160.,
    }

    ds = Dataset()
    r = ds.process(params)

    print r

    assert 'error' not in r
    assert 'img' not in r
    assert 'recimg' in r

    assert 'rec' in r['recimg']

    report(params, r['recimg'])