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
0
def test_Water_get(attr, unit, val, si_val):
    w = Water()
    setattr(w, attr, val)
    w.units[attr] = unit

    assert w.get(attr) == si_val
    assert w.get(attr, unit) == val
Exemplo n.º 3
0
def test_Water_get(attr, unit, val, si_val):
    w = Water()
    setattr(w, attr, val)
    w.units[attr] = unit

    assert w.get(attr) == si_val
    assert w.get(attr, unit) == val
Exemplo n.º 4
0
def test_exceptions(attr, unit):
    w = Water()

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

    with pytest.raises(InvalidUnitError):
        w.set(attr, 5, unit)
Exemplo n.º 5
0
def test_exceptions(attr, unit):
    w = Water()

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

    with pytest.raises(InvalidUnitError):
        w.set(attr, 5, unit)
Exemplo n.º 6
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()

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

    with pytest.raises(InvalidUnitError):
        w.set(attr, 5, unit)
Exemplo n.º 7
0
def test_properties_in_si(attr, unit, val, exp_si):
    '''
    set properties in non SI units and check default get() returns it in SI
    '''
    kw = {attr: val, 'units': {attr: unit}}
    w = Water(**kw)
    assert getattr(w, attr) == val
    assert w.units[attr] == unit

    assert w.get(attr) == exp_si
Exemplo n.º 8
0
def test_properties_in_si(attr, unit, val, exp_si):
    '''
    set properties in non SI units and check default get() returns it in SI
    '''
    kw = {attr: val, 'units': {attr: unit}}
    w = Water(**kw)
    assert getattr(w, attr) == val
    assert w.units[attr] == unit

    assert w.get(attr) == exp_si