From 1c075a28ac9582145cb606b1ca19d1739ea8859d Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 05:31:00 +0000 Subject: [PATCH] Add exporters, utils, and tests --- .tests/test_ascii.py | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .tests/test_ascii.py diff --git a/.tests/test_ascii.py b/.tests/test_ascii.py new file mode 100644 index 0000000..96392f0 --- /dev/null +++ b/.tests/test_ascii.py @@ -0,0 +1,78 @@ +"""Tests for ASCII generator.""" + +import pytest + +from termflow.exporters.ascii_generator import ASCIIGenerator, GitGraphGenerator + + +class TestASCIIGenerator: + """Test ASCII generator.""" + + def test_generate_empty(self): + """Test generating empty diagram.""" + gen = ASCIIGenerator() + result = gen.generate_from_commands([]) + assert result is not None + + def test_generate_single_command(self): + """Test generating diagram with single command.""" + gen = ASCIIGenerator() + result = gen.generate_from_commands(["ls -la"]) + assert "ls -la" in result + + def test_generate_multiple_commands(self): + """Test generating diagram with multiple commands.""" + gen = ASCIIGenerator() + commands = ["ls -la", "cd /tmp", "pwd"] + result = gen.generate_from_commands(commands) + for cmd in commands: + assert cmd in result + + def test_different_styles(self): + """Test different visualization styles.""" + commands = ["ls -la", "cd /tmp", "pwd"] + + for style in ["compact", "detailed", "minimal"]: + gen = ASCIIGenerator(style=style) + result = gen.generate_from_commands(commands, {"title": "Test"}) + assert result is not None + + def test_with_metadata(self): + """Test generating with metadata.""" + gen = ASCIIGenerator() + commands = ["ls -la", "cd /tmp"] + metadata = {"title": "Test Session", "command_count": len(commands)} + result = gen.generate_from_commands(commands, metadata) + assert "Test Session" in result + assert str(len(commands)) in result + + +class TestGitGraphGenerator: + """Test git graph generator.""" + + def test_generate_empty(self): + """Test generating empty graph.""" + gen = GitGraphGenerator() + + class MockParser: + commits = [] + + result = gen.generate_from_parser(MockParser()) + assert result is not None + + def test_generate_with_commits(self): + """Test generating graph with commits.""" + gen = GitGraphGenerator() + + class MockCommit: + def __init__(self, hash, message): + self.hash = hash + self.message = message + self.parents = [] + + class MockParser: + commits = [MockCommit("abc123", "Initial commit"), MockCommit("def456", "Add feature")] + + result = gen.generate_from_parser(MockParser()) + assert "abc123" in result + assert "def456" in result