From c2356d315b85272359306b6ee0db82adaccb96c9 Mon Sep 17 00:00:00 2001 From: vdayanand Date: Thu, 4 Jul 2024 14:48:03 +0530 Subject: [PATCH] update test --- test/param_serialize.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/param_serialize.jl b/test/param_serialize.jl index 8961b57..353e6b1 100644 --- a/test/param_serialize.jl +++ b/test/param_serialize.jl @@ -1,6 +1,7 @@ module ParamSerialization using Test using OpenAPI.Servers: deserialize_deep_object +using OpenAPI: convert_dicts_to_arrays @testset "Test deserialize_deep_object" begin @testset "Single level object" begin query_string = Dict("key1"=>"value1", "key2"=>"value2") @@ -27,13 +28,13 @@ using OpenAPI.Servers: deserialize_deep_object @testset "List of values" begin query_string = Dict("a[0]"=>"value1", "a[1]"=>"value2") - expected = Dict("a" => ["value1", "value2"]) + expected = Dict("a"=>Dict("0"=>"value1", "1"=>"value2")) @test deserialize_deep_object(query_string) == expected end @testset "Mixed structure" begin query_string = Dict("a[b]"=>"value1", "a[c][0]"=>"value2", "a[c][1]"=>"value3") - expected = Dict("a" => Dict("b" => "value1", "c" => ["value2", "value3"])) + expected = Dict("a" => Dict("b" => "value1", "c" => Dict("0"=>"value2", "1"=>"value3"))) @test deserialize_deep_object(query_string) == expected end @@ -48,7 +49,7 @@ using OpenAPI.Servers: deserialize_deep_object expected = Dict("a" => Dict("b" => Dict("c" => Dict("d" => "value1", "e" => "value2")), "f" => "value3")) @test deserialize_deep_object(query_string) == expected end - @testset "Complex nested structure with numbers and nested arrays" begin + @testset "Complex nested structure with numbers and nessted" begin query_string = Dict{String, String}( "filter[0][name]" => "name", "filter[0][data][0]" => "Dog", @@ -57,11 +58,11 @@ using OpenAPI.Servers: deserialize_deep_object "filter[0][type]" => "FilterSet", "pagination[per_page]" => "5", "pagination[foo]" => "5.0") expected = Dict( - "pagination" => Dict( "page" => 1, - "per_page" => 5, - "type" => "offset", "foo"=>5.0), - "filter"=>[Dict( - "name" => "name", "data" => ["Dog"], "type" => "FilterSet")] + "pagination" => Dict( "page" => "1", + "per_page" => "5", + "type" => "offset", "foo"=>"5.0"), + "filter"=>Dict("0"=>Dict( + "name" => "name", "data" => Dict("0"=>"Dog"), "type" => "FilterSet")) ) d = deserialize_deep_object(query_string) @test d["pagination"] == expected["pagination"]