def test_expand_braces_fail(): for expression in [ '{', '}', '{}', '{5', '{1}', 'A{-7}', 'A{', 'A{1', 'N{7', 'AN{7', 'A{4{}', 'A{4}{3}', 'A{b}', 'A{6X}', 'A{X6}' ]: with pytest.raises(ValueError): AdapterSpecification.expand_braces(expression)
def test_parse_misplaced_placement_restrictions(): with pytest.raises(ValueError) as e: AdapterSpecification._parse("A$", "front") assert "Allowed placement restrictions for a 5' adapter" in e.value.args[0] with pytest.raises(ValueError) as e: AdapterSpecification._parse("^A", "back") assert "Allowed placement restrictions for a 3' adapter" in e.value.args[0]
def test_parse_not_linked(): p = AdapterSpecification.parse assert p('A', 'front') == AdapterSpecification(None, None, 'A', {}, 'front') assert p('A', 'back') == AdapterSpecification(None, None, 'A', {}, 'back') assert p('A', 'anywhere') == AdapterSpecification(None, None, 'A', {}, 'anywhere') assert p('^A', 'front') == AdapterSpecification(None, 'anchored', 'A', {}, 'front') assert p('XXXA', 'front') == AdapterSpecification(None, 'noninternal', 'A', {}, 'front') assert p('A$', 'back') == AdapterSpecification(None, 'anchored', 'A', {}, 'back') assert p('AXXXX', 'back') == AdapterSpecification(None, 'noninternal', 'A', {}, 'back') assert p('a_name=ADAPT', 'front') == AdapterSpecification('a_name', None, 'ADAPT', {}, 'front')
def test_parse_double_placement_restrictions(spec, cmdline_type): with pytest.raises(ValueError) as e: AdapterSpecification._parse(spec, cmdline_type) assert "cannot use multiple placement restrictions" in e.value.args[0]
def test_parse_invalid_cmdline_type(): with pytest.raises(ValueError) as e: AdapterSpecification._parse('A', 'invalid_type') assert "cmdline_type must be front, back or anywhere" in e.value.args[0]
def test_restriction_to_class(): with pytest.raises(ValueError) as e: AdapterSpecification._restriction_to_class("anywhere", "noninternal") assert "No placement may be specified" in e.value.args[0]