@@ -197,18 +197,36 @@ def test_mcp_schema_validation_compatibility(self):
197197 assert "T" in datetime_str # Contains date-time separator
198198 assert len (datetime_str ) >= 19 # At least YYYY-MM-DDTHH:MM:SS format
199199
200- def test_all_models_have_json_encoders_configured (self ):
201- """Test that all memory schema models have datetime json_encoders configured."""
202- models_to_test = [EntitySummary , RelationSummary , ObservationSummary , MemoryMetadata ]
203-
204- for model_class in models_to_test :
205- # Check that ConfigDict with json_encoders is configured
206- assert hasattr (model_class , "model_config" )
207- assert "json_encoders" in model_class .model_config
208- assert datetime in model_class .model_config ["json_encoders" ]
209-
210- # Verify the encoder function produces ISO format
211- encoder = model_class .model_config ["json_encoders" ][datetime ]
200+ def test_all_models_have_datetime_serializers_configured (self ):
201+ """Test that all memory schema models have datetime field serializers configured."""
202+ models_to_test = [
203+ (EntitySummary , "created_at" ),
204+ (RelationSummary , "created_at" ),
205+ (ObservationSummary , "created_at" ),
206+ (MemoryMetadata , "generated_at" )
207+ ]
208+
209+ for model_class , datetime_field in models_to_test :
210+ # Create a test instance with a datetime field
212211 test_datetime = datetime (2023 , 12 , 8 , 10 , 30 , 0 )
213- result = encoder (test_datetime )
214- assert result == "2023-12-08T10:30:00"
212+
213+ if model_class == EntitySummary :
214+ instance = model_class (
215+ permalink = "test" , title = "Test" , file_path = "test.md" , created_at = test_datetime
216+ )
217+ elif model_class == RelationSummary :
218+ instance = model_class (
219+ title = "Test" , file_path = "test.md" , permalink = "test" ,
220+ relation_type = "test" , created_at = test_datetime
221+ )
222+ elif model_class == ObservationSummary :
223+ instance = model_class (
224+ title = "Test" , file_path = "test.md" , permalink = "test" ,
225+ category = "test" , content = "Test" , created_at = test_datetime
226+ )
227+ elif model_class == MemoryMetadata :
228+ instance = model_class (depth = 1 , generated_at = test_datetime )
229+
230+ # Test that model_dump produces ISO format for datetime field
231+ data = instance .model_dump ()
232+ assert data [datetime_field ] == "2023-12-08T10:30:00"
0 commit comments