@@ -127,3 +127,35 @@ def test_get_prep_value_with_none(self):
127127 # Should return None
128128 result = self .field .get_prep_value (None )
129129 self .assertIsNone (result )
130+
131+ def test_deconstruct_removes_block_lookup (self ):
132+ # Test that block_lookup is removed during deconstruction
133+ field = StreamField (self .block_types )
134+ field .block_lookup = {"some" : "value" } # Add block_lookup
135+ name , path , args , kwargs = field .deconstruct ()
136+ self .assertNotIn ("block_lookup" , kwargs )
137+
138+ def test_to_python_with_raw_text_and_child_blocks (self ):
139+ # Test that raw_text is properly handled when child_blocks exist
140+ field = StreamField (self .block_types ) # Field with child blocks
141+ value = "some raw text"
142+ result = field .to_python (value )
143+ self .assertIsInstance (result , StreamValue )
144+ self .assertEqual (len (result ), 0 ) # Should be empty as text isn't valid JSON
145+
146+ def test_deconstruct_with_block_types_in_kwargs (self ):
147+ # Test deconstruct when block_types is in kwargs but no args
148+ field = StreamField ()
149+ field .block_types = self .block_types # Add block_types to kwargs
150+ name , path , args , kwargs = field .deconstruct ()
151+ self .assertNotIn ("block_types" , kwargs )
152+
153+ def test_to_python_with_child_blocks (self ):
154+ # Test that to_python uses the parent class implementation when child_blocks exist
155+ field = StreamField (self .block_types ) # Field with child blocks
156+ value = [{"type" : "text" , "value" : "test" }]
157+ result = field .to_python (value )
158+ # Verify the value was processed by the parent class
159+ self .assertIsInstance (result , StreamValue )
160+ self .assertEqual (len (result ), 1 )
161+ self .assertEqual (result [0 ].value , "test" )
0 commit comments