diff --git a/tests/test_parsers.py b/tests/test_parsers.py index 85e3563..6aba6c3 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -1,85 +1,59 @@ import pytest -from datetime import datetime -from shell_history_search.parsers import ( - BashParser, - ZshParser, - FishParser, - parse_shell_history, -) -from shell_history_search.models import HistoryEntry +from shell_history_search.parsers.bash import BashHistoryParser +from shell_history_search.parsers.zsh import ZshHistoryParser +from shell_history_search.parsers.fish import FishHistoryParser +from shell_history_search.parsers.factory import get_all_parsers class TestBashParser: @pytest.fixture def parser(self): - return BashParser() + return BashHistoryParser() - def test_parse_single_entry(self, parser): - line = " 1234567890 ls -la" - entries = parser.parse(line) + def test_parse_single_entry(self, parser, tmp_path): + history_file = tmp_path / ".bash_history" + history_file.write_text("ls -la\n") + entries = list(parser.parse(history_file)) assert len(entries) == 1 assert entries[0].command == "ls -la" - def test_parse_with_heredoc(self, parser): - line = " 1234567890 cat <= 1 assert entries[0].command == "ls -la" - def test_parse_fish_multiline(self, parser): - lines = [ - "- cmd: ls -la", - " when: 1234567890", - "- cmd: echo test", - " when: 1234567891" - ] - entries = parser.parse_all(lines) - assert len(entries) == 2 - -class TestParseShellHistory: - def test_parse_shell_history_auto(self): - lines = [" 1234567890 ls -la"] - entries = parse_shell_history(lines, shell='auto') - assert len(entries) >= 1 +class TestParserFactory: + def test_get_all_parsers(self): + parsers = get_all_parsers() + assert len(parsers) == 3 + shell_types = {p.shell_type for p in parsers} + assert shell_types == {"bash", "zsh", "fish"}