From 7421d7da0fa4695997cda6ed1c7f2d155ecf9b2a Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 06:04:20 +0000 Subject: [PATCH] fix: resolve CI linting and type checking errors --- tests/test_parser.py | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_parser.py diff --git a/tests/test_parser.py b/tests/test_parser.py new file mode 100644 index 0000000..25a0399 --- /dev/null +++ b/tests/test_parser.py @@ -0,0 +1,50 @@ +"""Tests for pattern detection module.""" + +from cmdparse.patterns import detect_pattern_type + + +class TestDetectPatternType: + def test_empty_input_returns_empty(self): + assert detect_pattern_type("") == "empty" + assert detect_pattern_type(" ") == "empty" + assert detect_pattern_type("\n\n") == "empty" + + def test_table_detection(self): + table_input = """NAME IMAGE STATUS + nginx nginx:1 running + redis redis:3 stopped""" + result = detect_pattern_type(table_input) + assert result in ["table", "key_value_block"] + + def test_key_value_colon_detection(self): + kv_input = """name: John + age: 30 + city: NYC""" + result = detect_pattern_type(kv_input) + assert result == "key_value_colon" + + def test_key_value_equals_detection(self): + kv_input = """name=John + age=30 + city=NYC""" + result = detect_pattern_type(kv_input) + assert result == "key_value_equals" + + def test_delimited_comma_detection(self): + csv_input = """name,age,city + John,30,NYC + Jane,25,LA""" + result = detect_pattern_type(csv_input) + assert result == "delimited_comma" + + def test_delimited_tab_detection(self): + tsv_input = """name\tage\tcity + John\t30\tNYC""" + result = detect_pattern_type(tsv_input) + assert result == "delimited_tab" + + def test_raw_text_detection(self): + raw_input = """This is just some random text + Without any particular structure""" + result = detect_pattern_type(raw_input) + assert result in ["raw", "table", "key_value_block"]