Properly renamed single_shot_entry to single_entry

This commit is contained in:
2024-11-11 13:26:44 +01:00
parent 1a52205804
commit 0e1a0407d0
4 changed files with 26 additions and 26 deletions

View File

@@ -11,7 +11,7 @@ from sia.parse_error_entry import ParseErrorEntry
from sia.read_entry import ReadEntry
from sia.reasoning_entry import ReasoningEntry
from sia.repeat_entry import RepeatEntry
from sia.single_shot_entry import SingleShotEntry
from sia.single_entry import SingleEntry
from sia.write_entry import WriteEntry
from sia.web_io_buffer import WebIOBuffer
from sia.response_parser import ResponseParser
@@ -80,17 +80,17 @@ class ResponseParserTest(unittest.TestCase):
self.assertEqual(result.content, xml)
self.assertIn("missing script content", result.error)
def test_single_shot_entry(self):
def test_single_entry(self):
"""Test parsing single shot entry"""
xml = '<single_shot>echo "one time"</single_shot>'
xml = '<single>echo "one time"</single>'
result = self.parser.parse(xml)
self.assertIsInstance(result, SingleShotEntry)
self.assertIsInstance(result, SingleEntry)
self.assertEqual(result.script, 'echo "one time"')
def test_single_shot_entry_empty_script(self):
def test_single_entry_empty_script(self):
"""Test parsing single shot entry with empty script returns error entry"""
xml = '<single_shot/>'
xml = '<single/>'
result = self.parser.parse(xml)
self.assertIsInstance(result, ParseErrorEntry)
@@ -183,10 +183,10 @@ class ResponseParserTest(unittest.TestCase):
def test_script_with_special_characters(self):
"""Test parsing script with special characters"""
script = 'echo "Special chars: \n\t\r\'\"\\"'
xml = f'<single_shot>{script}</single_shot>'
xml = f'<single>{script}</single>'
result = self.parser.parse(xml)
self.assertIsInstance(result, SingleShotEntry)
self.assertIsInstance(result, SingleEntry)
self.assertEqual(result.script, script)
def test_cdata_content(self):
@@ -206,7 +206,7 @@ class ResponseParserTest(unittest.TestCase):
def test_error_in_content_extraction(self):
"""Test handling errors during content extraction"""
xml = '<single_shot><![CDATA[test]]>' # Malformed CDATA
xml = '<single><![CDATA[test]]>' # Malformed CDATA
result = self.parser.parse(xml)
self.assertIsInstance(result, ParseErrorEntry)

View File

@@ -2,9 +2,9 @@ import unittest
from datetime import datetime
import os
from sia.single_shot_entry import SingleShotEntry
from sia.single_entry import SingleEntry
class SingleShotEntryTest(unittest.TestCase):
class SingleEntryTest(unittest.TestCase):
def setUp(self):
"""Set up test cases with fixed id and timestamp"""
self.test_id = "test-id-1234"
@@ -26,7 +26,7 @@ class SingleShotEntryTest(unittest.TestCase):
def test_initialization(self):
"""Test entry initialization"""
script = "echo test"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
self.assertEqual(entry.script, script)
self.assertEqual(entry.stdout, "")
@@ -40,7 +40,7 @@ class SingleShotEntryTest(unittest.TestCase):
"""Test successful script execution"""
script = "echo 'test'"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
entry.update()
# Verify entry state
@@ -51,7 +51,7 @@ class SingleShotEntryTest(unittest.TestCase):
def test_failed_execution(self):
"""Test failed script execution with invalid command"""
entry = SingleShotEntry("nonexistentcommand", self.test_id, self.test_timestamp)
entry = SingleEntry("nonexistentcommand", self.test_id, self.test_timestamp)
entry.update()
# Verify entry state
@@ -64,7 +64,7 @@ class SingleShotEntryTest(unittest.TestCase):
"""Test script that creates a file"""
script = f"echo 'test' > {self.test_filename}"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
entry.update()
# Verify file was created and contains expected content
@@ -77,7 +77,7 @@ class SingleShotEntryTest(unittest.TestCase):
"""Test that script only executes once"""
script = f"echo 'test' >> {self.test_filename}"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
# Run update multiple times
entry.update()
@@ -92,11 +92,11 @@ class SingleShotEntryTest(unittest.TestCase):
def test_generate_context_before_execution(self):
"""Test XML context generation before execution"""
entry = SingleShotEntry("echo test", self.test_id, self.test_timestamp)
entry = SingleEntry("echo test", self.test_id, self.test_timestamp)
element = entry.generate_context()
# Verify XML structure
self.assertEqual(element.tag, "single_shot")
self.assertEqual(element.tag, "single")
self.assertEqual(element.get("id"), self.test_id)
self.assertEqual(element.text, "<![CDATA[echo test]]>")
@@ -109,12 +109,12 @@ class SingleShotEntryTest(unittest.TestCase):
"""Test XML context generation after execution"""
script = "echo 'test'"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
entry.update()
element = entry.generate_context()
# Verify XML structure
self.assertEqual(element.tag, "single_shot")
self.assertEqual(element.tag, "single")
self.assertEqual(element.get("id"), self.test_id)
self.assertEqual(element.text, f"<![CDATA[{script}]]>")
@@ -130,7 +130,7 @@ class SingleShotEntryTest(unittest.TestCase):
"""Test executing multiple commands in one script"""
script = f"echo 'first' > {self.test_filename} && echo 'second' >> {self.test_filename}"
entry = SingleShotEntry(script, self.test_id, self.test_timestamp)
entry = SingleEntry(script, self.test_id, self.test_timestamp)
entry.update()
# Verify file contains both lines