示例#1
0
def test_mean_sst_monthly(b, url):
    b.get(url)

    util.clear_cache('ERA')

    b.select_param('variable', 'Mean Temperature')
    b.ensure_selected('plottype', 'Surface Map', noptions=2)
    b.select_param('period', 'Monthly')
    b.select_param('month', 'January')
    b.select_param('year', '2012')

    assert b.select_contains('dataset', ['reynolds', 'ersst'])
    b.select_param('dataset', 'ERSST')

    b.submit()

    b.wait(output('ERA'))

    # check Bathymetry is enabled but not selected
    elem = b.find_element_by_xpath('//input[@value="Bathymetry"]')
    assert elem.get_attribute('checked') is None
    assert elem.get_attribute('disabled') is None

    # check Output is enabled and selected
    elem = b.find_element_by_xpath('//input[@value="Output"]')
    assert elem.get_attribute('checked')
    assert elem.get_attribute('disabled') is None
示例#2
0
def test_wave_watch_rose(b, url):
    b.get(url)

    util.clear_cache('WAV')

    b.select_param('variable', 'Mean Wave Direction')
    b.ensure_selected('plottype', 'Waverose')
    b.ensure_selected('period', 'Monthly')
    b.select_param('month', 'October')  # September and October had a bug
    b.ensure_selected('dataset', 'WaveWatch III')

    elem = b.find_element_by_id('latitude')
    elem.send_keys("-45")
    elem.send_keys(Keys.TAB)

    elem = b.switch_to_active_element()
    elem.send_keys("145")

    b.submit()

    b.wait(output('WAV'))

    # check Bathymetry is selected and enabled
    elem = b.find_element_by_xpath('//input[@value="Bathymetry"]')
    assert elem.get_attribute('checked')
    assert elem.get_attribute('disabled') is None

    # check Output is unselected and disabled
    elem = b.find_element_by_xpath('//input[@value="Output"]')
    assert elem.get_attribute('checked') is None
    assert elem.get_attribute('disabled')
示例#3
0
def test_ersst(report, variable, period):
    util.clear_cache('ERA')

    if variable == 'trend' and period == '12monthly':
        pytest.skip("Not useful")
    elif variable != 'trend' and period == 'yearly':
        pytest.skip("No data for this var/period")

    params = {
        'area': 'pac',
        'date': datetime.date(2000, 1, 1),
        'period': period,
        'variable': variable,
        'baseYear': 1950,
    }

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

    print r

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

    report(params, r['img'])
示例#4
0
def test_click_gauge(b, url):
    b.get(url)

    b.select_param('variable', 'Tidal Gauge')
    time.sleep(4) # wait for the map to stabilise
    b.wait(jquery('svg circle'))

    marker = b.find_element_by_jquery('svg circle:first')

    assert marker.get_attribute('stroke') == 'white'

    marker.click()

    assert marker.get_attribute('stroke') == 'red'

    # this will be the first value in the config file
    input = b.find_element_by_id('tidalgauge')
    assert input.get_attribute('value') == "Fiji - Suva"

    input = b.find_element_by_id('tgId')
    assert input.get_attribute('value') == 'IDO70063'

    util.clear_cache('SEA')
    b.submit()
    b.wait(output('SEA'))
示例#5
0
def test_reynolds(report, variable, period):

    if variable == 'dec' and period == 'daily':
        pytest.xfail("No data available for this var/period")
    elif variable == 'trend':
        pytest.skip("Record not long enough")

    util.clear_cache('REY')

    params = {
        'area': 'pac',
        'date': datetime.date(2000, 1, 1),
        'period': period,
        'variable': variable,
    }

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

    print r

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

    report(params, r['img'])
示例#6
0
def test_msla_validate_params_incomplete(report):
    util.clear_cache('SEA')

    params = {
        'variable': 'sla',
        'plot': 'map',
        'period': 'daily',
        'date': datetime.date(2015, 7, 9),
    }

    ds = Dataset()
    with pytest.raises(MissingParameter) as excinfo:
        r = ds.process(params)
    assert excinfo.value.message == "Missing parameter 'area'"
示例#7
0
def test_surface(report, variable, period):
    util.clear_cache('BRN')

    params = {
        'area': 'fiji',
        'date': datetime.date(2000, 1, 1),
        'period': period,
        'variable': variable,
    }

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

    print r

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

    report(params, r['img'])
示例#8
0
def test_surface_msla(report):
    util.clear_cache('SEA')

    params = {
        'variable': 'sla',
        'plot': 'map',
        'period': 'daily',
        'date': datetime.date(2015, 7, 6),
        'area': 'pac',
    }

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

    assert 'error' not in r
    assert 'img' in r
    assert 'mapimg' in r
    assert 'scale' in r

    report(params, r['img'])
示例#9
0
def test_xsection(report, var, period):
    util.clear_cache('BRN')

    params = {
        'area': 'pac',
        'date': datetime.date(2000, 1, 1),
        'period': period,
        'variable': var,
        'lat': -30.,
        'lon': 160.,
    }

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

    print r

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

    report(params, r['img'])
示例#10
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])
示例#11
0
def test_plot(report, variable, period):
    util.clear_cache('WAV')

    params = {
        'date': datetime.date(2000, 1, 1),
        'period': period,
        'variable': variable,
        'lllat': -30.,
        'lllon': 160.,
        'urlat': -30.,
        'urlon': 160.,
    }

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

    print r

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

    report(params, r['img'])
示例#12
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'])
示例#13
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'])
示例#14
0
def test_crosssection_zonal_meridional(report, lat, lon):
    util.clear_cache('BRN')

    params = {
        'area': 'pac',
        'date': datetime.date(2006, 1, 1),
        'period': 'monthly',
        'variable': 'temp',
        'lat': lat,
        'lon': lon,
    }

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

    print r

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

    assert ('%i' % abs(lat)) in r['img']
    assert ('%i' % abs(lon)) in r['img']

    report(params, r['img'])