Source code for pyrk.inp.tests.test_validation

from nose.tools import assert_equal, assert_almost_equal, assert_true, \
    assert_false, assert_raises, assert_is_instance, with_setup

from pyrk.inp import validation as v
from pyrk.utilities.ur import units


[docs]def test_ge_wrong_type(): val = "ten" valname = "testval" llim = 0 assert_raises(TypeError, v.validate_ge, valname, val, llim)
[docs]def test_ge_Quantity_type(): val = 10*units.meter valname = "testval" llim = 0*units.meter assert_equal(v.validate_ge(valname, val, llim), val)
[docs]def test_ge_right_type(): val = 10 valname = "testval" llim = 0 assert_equal(v.validate_ge(valname, val, llim), val)
[docs]def test_ge_too_small(): val = -2 valname = "testval" llim = 0 assert_raises(ValueError, v.validate_ge, valname, val, llim)
[docs]def test_ge_both_neg(): val = -2 valname = "testval" llim = -3 assert_equal(v.validate_ge(valname, val, llim), val)
[docs]def test_le_wrong_type(): val = "ten" valname = "testval" ulim = 20 assert_raises(TypeError, v.validate_le, valname, val, ulim)
[docs]def test_le_right_type(): val = 1 valname = "testval" ulim = 10 assert_equal(v.validate_le(valname, val, ulim), val)
[docs]def test_le_too_big(): val = 2 valname = "testval" ulim = 0 assert_raises(ValueError, v.validate_le, valname, val, ulim)
[docs]def test_le_both_large(): val = 1000000000000000 valname = "testval" ulim = val assert_equal(v.validate_le(valname, val, ulim), val)
[docs]def test_num_Quantity_type(): val = 10*units.meter valname = "testval" assert_equal(v.validate_num(valname, val), val)