Exemplo n.º 1
1
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)
Exemplo n.º 2
1
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
Exemplo n.º 3
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)
Exemplo n.º 4
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