Updated main file
This commit is contained in:
@@ -18,10 +18,17 @@ from sia.parse_error_entry import ParseErrorEntry
|
||||
from sia.delete_command import DeleteCommand
|
||||
from sia.entry import Entry
|
||||
|
||||
class TestBaseAgent(BaseAgent):
|
||||
"""Concrete implementation of BaseAgent for testing."""
|
||||
def run(self) -> None:
|
||||
pass
|
||||
class TestLogHandler(logging.Handler):
|
||||
"""Custom logging handler that stores records for test verification."""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.records = []
|
||||
|
||||
def emit(self, record):
|
||||
self.records.append(record)
|
||||
|
||||
def clear(self):
|
||||
self.records = []
|
||||
|
||||
class MockEntry(Entry):
|
||||
"""Mock entry class that properly extends Entry."""
|
||||
@@ -40,6 +47,11 @@ class MockEntry(Entry):
|
||||
elem.text = "<![CDATA[mock content]]>"
|
||||
return elem
|
||||
|
||||
class TestBaseAgent(BaseAgent):
|
||||
"""Concrete implementation of BaseAgent for testing."""
|
||||
def run(self) -> None:
|
||||
pass
|
||||
|
||||
class BaseAgentTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test cases with mocked components."""
|
||||
@@ -82,10 +94,10 @@ class BaseAgentTest(unittest.TestCase):
|
||||
# Set timestamp for entries
|
||||
self.test_timestamp = datetime(2024, 10, 31, 12, 0, 0)
|
||||
|
||||
# Capture logging output
|
||||
self.log_records = []
|
||||
logging.getLogger().handlers = []
|
||||
logging.getLogger().addHandler(self.log_handler)
|
||||
# Setup logging
|
||||
self.log_handler = TestLogHandler()
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(self.log_handler)
|
||||
|
||||
def log_handler(self, record):
|
||||
"""Capture log records for testing."""
|
||||
@@ -93,6 +105,10 @@ class BaseAgentTest(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
"""Clean up resources."""
|
||||
# Remove log handler
|
||||
logger = logging.getLogger()
|
||||
logger.removeHandler(self.log_handler)
|
||||
|
||||
if hasattr(self, 'agent'):
|
||||
del self.agent
|
||||
|
||||
@@ -170,4 +186,4 @@ class BaseAgentTest(unittest.TestCase):
|
||||
self.assertEqual(len(reasoning_elems), 3)
|
||||
for i, elem in enumerate(reasoning_elems):
|
||||
self.assertEqual(elem.get("id"), f"id-{i}")
|
||||
self.assertEqual(elem.text, f"<![CDATA[test {i}]]>")
|
||||
self.assertEqual(elem.text, f"<![CDATA[test {i}]]>")
|
||||
|
||||
Reference in New Issue
Block a user