fix: resolve F401 unused import lint errors in CI
This commit is contained in:
@@ -1 +1,66 @@
|
||||
bmFtZTogQ0kKCm9uOgogIHB1c2g6CiAgICBicmFuY2hlczogW21haW5dCiAgcHVsbF9yZXF1ZXN0OgogICAgYnJhbmNoZXM6IFttYWluXQoKam9iczogCiAgdGVzdDoKICAgIHJ1bnMtb246IHVidW50dS1sYXRlc3QKICAgIHN0ZXBzOgogICAgICAtIHVzZXM6IGFjdGlvbnMvY2hlY2tvdXQdjNFgKICAgICAgdXNlczogYWN0aW9ucy9zZXR1cC1weXRob25fdjUKICAgICAgd2l0aDoKICAgICAgICBweXRob24tdmVyc2lvbjogJzMuMTEnCiAgICAtIHJ1bjogcGlwIGluc3RhbGwgLWUgIltcImRldlwiXSIKICAgIC0gcnVuOiBweXRlc3QgdGVzdHMvIC12CiAgICAtIHJ1bjogcnVmZiBjaGVjayAu
|
||||
"""Tests for time analysis functionality."""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from io import StringIO
|
||||
|
||||
|
||||
from shellhist.core import HistoryEntry, HistoryStore
|
||||
|
||||
|
||||
class TestTimeUtils:
|
||||
"""Test time utility functions."""
|
||||
|
||||
def test_parse_time_range_hours(self):
|
||||
"""Test parsing hour-based time range."""
|
||||
from shellhist.cli.time_analysis import _parse_time_range
|
||||
|
||||
result = _parse_time_range("24h")
|
||||
expected = datetime.now() - timedelta(hours=24)
|
||||
|
||||
assert (result - expected).total_seconds() < 5
|
||||
|
||||
def test_parse_time_range_days(self):
|
||||
"""Test parsing day-based time range."""
|
||||
from shellhist.cli.time_analysis import _parse_time_range
|
||||
|
||||
result = _parse_time_range("7d")
|
||||
expected = datetime.now() - timedelta(days=7)
|
||||
|
||||
assert (result - expected).total_seconds() < 5
|
||||
|
||||
def test_parse_time_range_weeks(self):
|
||||
"""Test parsing week-based time range."""
|
||||
from shellhist.cli.time_analysis import _parse_time_range
|
||||
|
||||
result = _parse_time_range("2w")
|
||||
expected = datetime.now() - timedelta(weeks=2)
|
||||
|
||||
assert (result - expected).total_seconds() < 5
|
||||
|
||||
|
||||
class TestHourlyDistribution:
|
||||
"""Test hourly distribution analysis."""
|
||||
|
||||
def test_hourly_analysis(self):
|
||||
"""Test basic hourly distribution."""
|
||||
from shellhist.cli.time_analysis import _analyze_hourly_distribution
|
||||
from rich.console import Console
|
||||
|
||||
store = HistoryStore()
|
||||
now = datetime.now()
|
||||
|
||||
for i in range(24):
|
||||
entry = HistoryEntry(
|
||||
command="test command",
|
||||
timestamp=now.replace(hour=i),
|
||||
)
|
||||
store.add_entry(entry)
|
||||
|
||||
console = Console()
|
||||
output = StringIO()
|
||||
console.file = output
|
||||
|
||||
_analyze_hourly_distribution(console, list(store.entries))
|
||||
|
||||
result = output.getvalue()
|
||||
assert "Hourly Command Distribution" in result
|
||||
|
||||
Reference in New Issue
Block a user