Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
vdayanand committed Jul 4, 2024
1 parent d76ec36 commit c2356d3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/param_serialize.jl
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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

Expand All @@ -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",
Expand All @@ -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"]
Expand Down

0 comments on commit c2356d3

Please sign in to comment.