Begin work on context template
This commit is contained in:
34
test/context_template_test.py
Normal file
34
test/context_template_test.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
from sia.context_template import generate_context
|
||||
|
||||
class TestContextTemplate(unittest.TestCase):
|
||||
def test_empty_containers(self):
|
||||
"""Test context generation with no containers."""
|
||||
context = generate_context([])
|
||||
self.assertIn("<context>", context)
|
||||
self.assertIn("<containers />", context)
|
||||
self.assertIn("</context>", context)
|
||||
|
||||
def test_single_container(self):
|
||||
"""Test context generation with a single container."""
|
||||
container_status = {
|
||||
'name': 'test-container',
|
||||
'status': 'running',
|
||||
'started_at': '2024-10-25T10:00:00Z',
|
||||
'stdout_size': 100,
|
||||
'stderr_size': 50
|
||||
}
|
||||
context = generate_context([container_status])
|
||||
print(f"context: {context}")
|
||||
self.assertIn("<context>", context)
|
||||
self.assertIn("<containers", context)
|
||||
self.assertIn('name="test-container"', context)
|
||||
self.assertIn('status="running"', context)
|
||||
self.assertIn('started_at="2024-10-25T10:00:00Z"', context)
|
||||
self.assertIn('stdout="100"', context)
|
||||
self.assertIn('stderr="50"', context)
|
||||
self.assertIn("</context>", context)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user