From 36494cdaf60b72fc4b48837f2341c7f9ab319115 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 02:08:48 +0000 Subject: [PATCH] Initial upload: cmdparse CLI tool with comprehensive documentation and CI/CD --- tests/test_parser.py | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 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..09ac445 --- /dev/null +++ b/tests/test_parser.py @@ -0,0 +1,51 @@ +"""Tests for pattern detection module.""" + +import pytest +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']