diff --git a/app/tests/test_patterns.py b/app/tests/test_patterns.py new file mode 100644 index 0000000..410ad08 --- /dev/null +++ b/app/tests/test_patterns.py @@ -0,0 +1,36 @@ +import pytest +from cmdparse.patterns import detect_pattern_type, PATTERNS + + +def test_detect_table_with_pipes(): + """Test detection of table format with pipe separators.""" + text = "| Name | Age |\n| Alice | 30 |" + assert detect_pattern_type(text) == 'table' + + +def test_detect_key_value_colon(): + """Test detection of key-value with colon.""" + text = "key1: value1\nkey2: value2" + assert detect_pattern_type(text) == 'key_value_colon' + + +def test_detect_delimited_tab(): + """Test detection of tab-delimited format.""" + text = "name\tage\tcity\nalice\t30\tnyc" + assert detect_pattern_type(text) == 'delimited_tab' + + +def test_detect_empty(): + """Test detection of empty input.""" + assert detect_pattern_type("") == 'empty' + + +def test_detect_raw(): + """Test detection of raw/unstructured text.""" + text = "some random text without pattern" + assert detect_pattern_type(text) == 'raw' + + +def test_patterns_not_empty(): + """Test that PATTERNS list is not empty.""" + assert len(PATTERNS) > 0