From fd995399d110e84891fb5aedf0a66fe6aa131dac Mon Sep 17 00:00:00 2001 From: Luke Kiernan Date: Mon, 29 Jun 2026 16:43:04 -0600 Subject: [PATCH] Add JSON round-trip test for TupleTimeSeries serialization Strengthens the TupleTimeSeries serialization round-trip coverage with a true JSON-string round-trip for both arity-2 and arity-3 shapes. The NamedTuple field names ride on PARAMETERS_KEY as a JSON array of strings; round-tripping through JSON.json -> JSON.parse (dicttype Dict{String, Any}) mimics the on-disk format and verifies the concrete type, instance type, underlying NamedTuple type, and time-series key survive the cycle. Closes #568. Co-Authored-By: Claude Opus 4.8 (1M context) --- test/test_tuple_time_series.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test_tuple_time_series.jl b/test/test_tuple_time_series.jl index 14b0a3bb9..490a55a57 100644 --- a/test/test_tuple_time_series.jl +++ b/test/test_tuple_time_series.jl @@ -157,6 +157,29 @@ data2 = IS.serialize_struct(tts2) tts2_rt = IS.deserialize(IS.get_type_from_serialization_data(data2), data2) @test tts2_rt isa IS.TupleTimeSeries{MinMax} + + # Round-trip through a JSON string to mimic the on-disk format: the + # NamedTuple field names ride PARAMETERS_KEY as a JSON array of strings + # and must survive a JSON encode/parse cycle (which retypes the Dict to + # Dict{String, Any} and strings to plain `String`). + for (T, key) in ((StartUpStages, static_key), (MinMax, static_key)) + tts = IS.TupleTimeSeries{T}(key) + json_data = JSON.parse( + JSON.json(IS.serialize_struct(tts)); + dicttype = Dict{String, Any}, + ) + @test IS.get_type_from_serialization_data(json_data) === + IS.TupleTimeSeries{T} + json_rt = IS.deserialize( + IS.get_type_from_serialization_data(json_data), json_data, + ) + @test json_rt isa IS.TupleTimeSeries{T} + @test IS.get_underlying_namedtuple_type(json_rt) === T + json_rt_key = IS.get_time_series_key(json_rt) + @test IS.get_name(json_rt_key) == IS.get_name(key) + @test IS.get_time_series_type(json_rt_key) === + IS.get_time_series_type(key) + end end @testset "build_static_tuple round-trip (HDF5)" begin