def test_unit_errors(attr, unit):
    '''
        - currently salinity only has psu in there since there is
          no conversion from psu to ppt, though ppt is a valid unit.
          This needs to be fixed
        - similarly, sediment only has mg/l as units.  We need to decide
          if we want more units here
    '''
    w = Water()
    w.wave_height = 1
    w.fetch = 10000

    with pytest.raises(InvalidUnitError):
        w.get(attr, unit)

    with pytest.raises(InvalidUnitError):
        w.set(attr, 5, unit)
def test_Water_update_from_dict():
    '''
    test that the update_from_dict correctly sets fetch and wave_height to None
    if it is dropped from json payload so user chose compute from wind option.
    '''
    w = Water()
    json_ = w.serialize()
    w.fetch = 0.0
    w.wave_height = 1.0
    json_with_values = w.serialize()

    w.update_from_dict(json_)
    assert w.fetch is None
    assert w.wave_height is None

    w.update_from_dict(json_with_values)
    assert w.fetch == 0.0
    assert w.wave_height == 1.0
Beispiel #3
0
def test_get_emulsification_wind_with_wave_height2():
    wind = constant_wind(10., 0)
    water = Water()
    water.wave_height = 2.0
    w = Waves(wind, water)

    print w.get_value(start_time)

    print w.get_emulsification_wind(start_time)
    # input wave height should not have overwhelmed wind speed
    assert w.get_emulsification_wind(start_time) == 10.0
Beispiel #4
0
def test_get_emulsification_wind_with_wave_height():
    wind = constant_wind(3., 0)
    water = Water()
    water.wave_height = 2.0
    w = Waves(wind, water)

    print w.get_value(start_time)

    print w.get_emulsification_wind(start_time)
    # input wave height should hav overwhelmed
    assert w.get_emulsification_wind(start_time) > 3.0
Beispiel #5
0
def test_unit_errors(attr, unit):
    '''
        - currently salinity only has psu in there since there is
          no conversion from psu to ppt, though ppt is a valid unit.
          This needs to be fixed
        - similarly, sediment only has mg/l as units.  We need to decide
          if we want more units here
    '''
    w = Water()
    w.wave_height = 1
    w.fetch = 10000

    with pytest.raises(InvalidUnitError):
        w.get(attr, unit)

    with pytest.raises(InvalidUnitError):
        w.set(attr, 5, unit)
Beispiel #6
0
def test_Water_update_from_dict():
    '''
    test that the update_from_dict correctly sets fetch and wave_height to None
    if it is dropped from json payload so user chose compute from wind option.
    '''
    w = Water()
    json_ = w.serialize()
    w.fetch = 0.0
    w.wave_height = 1.0
    json_with_values = w.serialize()

    w.update_from_dict(Water.deserialize(json_))
    assert w.fetch is None
    assert w.wave_height is None

    w.update_from_dict(Water.deserialize(json_with_values))
    assert w.fetch == 0.0
    assert w.wave_height == 1.0