@@ -20,8 +20,16 @@ def setUp(self):
2020 pattern_id = "test_pattern" ,
2121 start_pattern = "<test>" ,
2222 end_pattern = "</test>" ,
23+ type = "test" ,
2324 remove_match = True ,
2425 )
26+ self .aggregator .add_pattern_pair (
27+ pattern_id = "code_pattern" ,
28+ start_pattern = "<code>" ,
29+ end_pattern = "</code>" ,
30+ type = "code" ,
31+ remove_match = False ,
32+ )
2533
2634 # Register the mock handler
2735 self .aggregator .on_pattern_match ("test_pattern" , self .test_handler )
@@ -30,7 +38,8 @@ async def test_pattern_match_and_removal(self):
3038 # First part doesn't complete the pattern
3139 result = await self .aggregator .aggregate ("Hello <test>pattern" )
3240 self .assertIsNone (result )
33- self .assertEqual (self .aggregator .text , "Hello <test>pattern" )
41+ self .assertEqual (self .aggregator .text .text , "Hello <test>pattern" )
42+ self .assertEqual (self .aggregator .text .type , "test" )
3443
3544 # Second part completes the pattern and includes an exclamation point
3645 result = await self .aggregator .aggregate (" content</test>!" )
@@ -45,14 +54,15 @@ async def test_pattern_match_and_removal(self):
4554
4655 # The exclamation point should be treated as a sentence boundary,
4756 # so the result should include just text up to and including "!"
48- self .assertEqual (result , "Hello !" )
57+ self .assertEqual (result .text , "Hello !" )
58+ self .assertEqual (result .type , "sentence" )
4959
5060 # Next sentence should be processed separately
5161 result = await self .aggregator .aggregate (" This is another sentence." )
52- self .assertEqual (result , " This is another sentence." )
62+ self .assertEqual (result . text , " This is another sentence." )
5363
5464 # Buffer should be empty after returning a complete sentence
55- self .assertEqual (self .aggregator .text , "" )
65+ self .assertEqual (self .aggregator .text . text , "" )
5666
5767 async def test_incomplete_pattern (self ):
5868 # Add text with incomplete pattern
@@ -65,11 +75,12 @@ async def test_incomplete_pattern(self):
6575 self .test_handler .assert_not_called ()
6676
6777 # Buffer should contain the incomplete text
68- self .assertEqual (self .aggregator .text , "Hello <test>pattern content" )
78+ self .assertEqual (self .aggregator .text .text , "Hello <test>pattern content" )
79+ self .assertEqual (self .aggregator .text .type , "test" )
6980
7081 # Reset and confirm buffer is cleared
7182 await self .aggregator .reset ()
72- self .assertEqual (self .aggregator .text , "" )
83+ self .assertEqual (self .aggregator .text . text , "" )
7384
7485 async def test_multiple_patterns (self ):
7586 # Set up multiple patterns and handlers
@@ -109,7 +120,7 @@ async def test_multiple_patterns(self):
109120 self .assertEqual (result , "Hello I am <em>very</em> excited to meet you!" )
110121
111122 # Buffer should be empty
112- self .assertEqual (self .aggregator .text , "" )
123+ self .assertEqual (self .aggregator .text . text , "" )
113124
114125 async def test_handle_interruption (self ):
115126 # Start with incomplete pattern
@@ -120,7 +131,7 @@ async def test_handle_interruption(self):
120131 await self .aggregator .handle_interruption ()
121132
122133 # Buffer should be cleared
123- self .assertEqual (self .aggregator .text , "" )
134+ self .assertEqual (self .aggregator .text . text , "" )
124135
125136 # Handler should not have been called
126137 self .test_handler .assert_not_called ()
@@ -144,4 +155,4 @@ async def test_pattern_across_sentences(self):
144155 self .assertEqual (result , "Hello Final sentence." )
145156
146157 # Buffer should be empty
147- self .assertEqual (self .aggregator .text , "" )
158+ self .assertEqual (self .aggregator .text . text , "" )
0 commit comments