def test_specs__path_is_displayed_in_exception(): def _path_is_displayed_in_exception(spec, value): assert_raises_regexp(MakefileError, _DUMMY_PATH_STR, spec, _DUMMY_PATH, value) yield _path_is_displayed_in_exception, IsInt(), "foo" yield _path_is_displayed_in_exception, IsUnsignedInt(), -1 yield _path_is_displayed_in_exception, IsFloat(), "abc" yield _path_is_displayed_in_exception, IsBoolean(), 1 yield _path_is_displayed_in_exception, IsStr(), 1 yield _path_is_displayed_in_exception, IsNone(), 1 yield _path_is_displayed_in_exception, ValueLT(0), 1 yield _path_is_displayed_in_exception, ValueLE(0), 1 yield _path_is_displayed_in_exception, ValueGE(0), -1 yield _path_is_displayed_in_exception, ValueGT(0), -1 yield _path_is_displayed_in_exception, ValueIn([1]), 2 yield _path_is_displayed_in_exception, ValuesIntersect([1]), [2] yield _path_is_displayed_in_exception, ValuesSubsetOf([1]), [2] yield _path_is_displayed_in_exception, ValueMissing(), True yield _path_is_displayed_in_exception, And(IsStr), 1 yield _path_is_displayed_in_exception, Or(IsStr), 1 yield _path_is_displayed_in_exception, Xor(IsStr, IsInt), True yield _path_is_displayed_in_exception, Not(IsInt), 1 yield _path_is_displayed_in_exception, StringIn("abc"), 1 yield _path_is_displayed_in_exception, StringsIntersect("abc"), [1] yield _path_is_displayed_in_exception, StringsSubsetOf("abc"), [1] yield _path_is_displayed_in_exception, StringIsUppercase(), 1 yield _path_is_displayed_in_exception, StringStartsWith("FOO"), 1 yield _path_is_displayed_in_exception, StringEndsWith("FOO"), 1 yield _path_is_displayed_in_exception, IsListOf(IsInt), "foo" yield _path_is_displayed_in_exception, IsDictOf(IsInt, IsInt), 1
def test_subset_of__rejects_dictionary(): spec = ValuesIntersect("abc") assert_raises(MakefileError, spec, _DUMMY_PATH, {"a": 1, "b": 2})
def test_intersects__default_set__valid_value(): spec = ValuesIntersect(range(5), default=[3, 4]) assert_equal(spec.default, [3, 4])
def test_intersects__default_not_set(): spec = ValuesIntersect(range(5)) assert_is(spec.default, DEFAULT_NOT_SET)
def test_intersects__chars__case_sensitive__rejects_differences_in_case(): spec = ValuesIntersect("abcdefghijkl") assert_raises(MakefileError, spec, _DUMMY_PATH, "A BIG DEAL")
def test_intersects__chars__case_sensitive(): spec = ValuesIntersect("abcdefghijkl") spec(_DUMMY_PATH, "a big deal")
def test_intersects__case_sensitive__value_in_not_set(): spec = ValuesIntersect(("Abc", "bCe", "cdE")) assert_raises(MakefileError, spec, _DUMMY_PATH, ["Bce"])
def test_intersects__case_sensitive__value_in_set(): spec = ValuesIntersect(("Abc", "bCe", "cdE")) spec(_DUMMY_PATH, ["bCe"])
def test_intersects__empty_set(): spec = ValuesIntersect(range(5)) assert_raises(MakefileError, spec, _DUMMY_PATH, [])
def test_intersects__some_values_in_set(): spec = ValuesIntersect(range(5)) spec(_DUMMY_PATH, [4, 5])
def test_intersects__single_value_not_in_set(): spec = ValuesIntersect(range(5)) assert_raises(MakefileError, spec, _DUMMY_PATH, [5])
def test_intersects__multiple_values_in_set(): spec = ValuesIntersect(range(5)) spec(_DUMMY_PATH, [1, 4])
def test_intersects__single_value_in_set(): spec = ValuesIntersect(range(5)) spec(_DUMMY_PATH, [1])
description = "characters a-z, A-Z, 0-9%s allowed" description %= (", and %r" % whitelist, ) if whitelist else "" whitelist += string.ascii_letters + string.digits return And(IsStr(), ValuesSubsetOf(whitelist, description=description)) # Valid names for prefixes _VALID_PREFIX_NAME = \ And(_alphanum_check(whitelist="._-*"), Not(StringIn(["Options"] + [(s + "Reads") for s in _READ_TYPES]))) # Valid paths for prefixes; avoids some problems with e.g. Bowtie2 _VALID_PREFIX_PATH = \ And(IsStr(), Not(ValuesIntersect("\\:?\"<>|() \t\n\v\f\r")), default=REQUIRED_VALUE) # Valid strings for targets / samples / libraries / lanes _VALID_TARGET_NAME = \ And(_alphanum_check(whitelist="._-"), ValueGE(2, key=len, description="at least two characters long")) _VALIDATION_OPTIONS = { # Sequencing platform, used to tag read-groups. "Platform": StringIn(("CAPILLARY", "LS454", "ILLUMINA", "SOLID", "HELICOS", "IONTORRENT", "PACBIO"), default="ILLUMINA"), # Offset for quality scores in FASTQ files. "QualityOffset":