Add test files (unit and integration tests)
Some checks failed
Some checks failed
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
"""Unit tests for CLI commands."""
|
"""Unit tests for CLI commands."""
|
||||||
|
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from unittest.mock import patch, MagicMock
|
|
||||||
import sys
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
from loglens.cli.commands import analyze, watch, report, patterns, info
|
from loglens.cli.commands import analyze, info, patterns, report, watch
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -18,7 +17,7 @@ def runner():
|
|||||||
class TestAnalyzeCommand:
|
class TestAnalyzeCommand:
|
||||||
"""Tests for analyze command."""
|
"""Tests for analyze command."""
|
||||||
|
|
||||||
@patch('loglens.cli.commands.LogAnalyzer')
|
@patch("loglens.cli.commands.LogAnalyzer")
|
||||||
def test_analyze_file(self, mock_analyzer_class, runner, tmp_path):
|
def test_analyze_file(self, mock_analyzer_class, runner, tmp_path):
|
||||||
"""Test analyzing a log file."""
|
"""Test analyzing a log file."""
|
||||||
mock_analyzer = MagicMock()
|
mock_analyzer = MagicMock()
|
||||||
@@ -43,7 +42,7 @@ class TestAnalyzeCommand:
|
|||||||
|
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
@patch('loglens.cli.commands.LogAnalyzer')
|
@patch("loglens.cli.commands.LogAnalyzer")
|
||||||
def test_analyze_json_output(self, mock_analyzer_class, runner, tmp_path):
|
def test_analyze_json_output(self, mock_analyzer_class, runner, tmp_path):
|
||||||
"""Test analyze with JSON output."""
|
"""Test analyze with JSON output."""
|
||||||
mock_analyzer = MagicMock()
|
mock_analyzer = MagicMock()
|
||||||
@@ -90,7 +89,7 @@ class TestWatchCommand:
|
|||||||
class TestReportCommand:
|
class TestReportCommand:
|
||||||
"""Tests for report command."""
|
"""Tests for report command."""
|
||||||
|
|
||||||
@patch('loglens.cli.commands.LogAnalyzer')
|
@patch("loglens.cli.commands.LogAnalyzer")
|
||||||
def test_report_to_file(self, mock_analyzer_class, runner, tmp_path):
|
def test_report_to_file(self, mock_analyzer_class, runner, tmp_path):
|
||||||
"""Test report generation to file."""
|
"""Test report generation to file."""
|
||||||
mock_analyzer = MagicMock()
|
mock_analyzer = MagicMock()
|
||||||
@@ -118,7 +117,7 @@ class TestReportCommand:
|
|||||||
class TestPatternsCommand:
|
class TestPatternsCommand:
|
||||||
"""Tests for patterns command."""
|
"""Tests for patterns command."""
|
||||||
|
|
||||||
@patch('loglens.cli.commands.LogAnalyzer')
|
@patch("loglens.cli.commands.LogAnalyzer")
|
||||||
def test_list_patterns(self, mock_analyzer_class, runner):
|
def test_list_patterns(self, mock_analyzer_class, runner):
|
||||||
"""Test listing patterns."""
|
"""Test listing patterns."""
|
||||||
mock_analyzer = MagicMock()
|
mock_analyzer = MagicMock()
|
||||||
|
|||||||
Reference in New Issue
Block a user