Initial upload: cmdparse CLI tool with comprehensive documentation and CI/CD

This commit is contained in:
2026-02-04 02:08:48 +00:00
parent 2734877ddb
commit 36494cdaf6

51
tests/test_parser.py Normal file
View File

@@ -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']