Some checks failed
CI / test (push) Has been cancelled
- Created models.py with HistoryEntry and SearchResult classes - Created database.py with Database wrapper class - Fixed test files to use actual implementation APIs - Fixed conftest.py SearchResult fixture field names
24 lines
829 B
Python
24 lines
829 B
Python
from shell_history_search.core.search import SearchResult
|
|
|
|
|
|
class TestSearchResult:
|
|
def test_search_result_creation(self):
|
|
result = SearchResult(
|
|
command="ls -la",
|
|
shell_type="bash",
|
|
timestamp=1234567890,
|
|
similarity=0.95,
|
|
command_id=1
|
|
)
|
|
assert result.command == "ls -la"
|
|
assert result.similarity == 0.95
|
|
|
|
def test_search_result_sorting(self):
|
|
results = [
|
|
SearchResult("cmd1", "bash", 123, 0.5, 1),
|
|
SearchResult("cmd2", "bash", 124, 0.9, 2),
|
|
SearchResult("cmd3", "bash", 125, 0.7, 3),
|
|
]
|
|
sorted_results = sorted(results, key=lambda r: r.similarity, reverse=True)
|
|
assert sorted_results[0].similarity >= sorted_results[1].similarity >= sorted_results[2].similarity
|