def test_parsing_without_separators(self): rules.reset_rules() rules.add_rule('lights', '{category}{function}{whatAffects}{digits}{type}') name = 'dramatic_bounce_chars_001_LGT' parsed = n.parse(name) assert parsed is None
def test_parse_anchoring_start(self): rules.reset_rules() rules.add_rule('anchoring', '{awesometoken}_crazy_hardcoded_value', rules.Rule.ANCHOR_START) name = 'hello_crazy_hardcoded_value' parsed = n.parse(name) assert parsed == {'awesometoken': 'hello'}
def test_parse_anchoring_end(self): rules.reset_rules() rules.add_rule('anchoring', 'crazy_hardcoded_value_{awesometoken}', rules.Rule.ANCHOR_END) name = 'crazy_hardcoded_value_bye' parsed = n.parse(name) assert parsed == {'awesometoken': 'bye'}
def test_parse_anchoring_both(self): rules.reset_rules() rules.add_rule('anchoring', '{awesometoken}_crazy_hardcoded_value_{awesometoken}', rules.Rule.ANCHOR_BOTH) name = 'hello_crazy_hardcoded_value_bye' parsed = n.parse(name) assert parsed == {'awesometoken1': 'hello', 'awesometoken2': 'bye'}
def test_suffix_only(self): name = 'natural_custom_chars_0062rt_LGT' tokens.remove_token('number') tokens.add_token_number('number', suffix='rt', padding=4) parsed = n.parse(name) assert parsed['category'] == 'natural' assert parsed['function'] == 'custom' assert parsed['whatAffects'] == 'chars' assert parsed['number'] == 62 assert parsed['type'] == 'lighting'
def test_parsing_with_separators(self): rules.reset_rules() rules.add_rule('lights', '{category}_{function}_{whatAffects}_{digits}_{type}') name = 'dramatic_bounce_chars_001_LGT' parsed = n.parse(name) assert parsed['category'] == 'dramatic' assert parsed['function'] == 'bounce' assert parsed['whatAffects'] == 'chars' assert parsed['digits'] == 1 assert parsed['type'] == 'lighting'
def test_parse_repeated_tokens(self): name = "C-FRONT_L-ORBI_R-ZYGO" expected = { "side1": "center", "region1": "frontal", "side2": "left", "region2": "orbital", "side3": "right", "region3": "zygomatic" } result = n.parse(name) assert result == expected
def test_parse_repeated_tokens_missing_some(self): name = "C-FRONT_-ORBI_R" with pytest.raises(ParsingError) as exception: n.parse(name) assert str( exception.value).startswith("Separators count mismatch") is True