-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
25 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,45 @@ | ||
using OpenAPI.Clients: serialize_to_query_dict | ||
@testset "Test serialize_to_query_dict" begin | ||
using OpenAPI.Clients: deep_object_serialize | ||
|
||
@testset "Test deep_object_serialize" begin | ||
@testset "Single level object" begin | ||
dict = Dict("key1" => "value1", "key2" => "value2") | ||
expected = Dict("key1" => "value1", "key2" => "value2") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Nested object" begin | ||
dict = Dict("outer" => Dict("inner" => "value")) | ||
expected = Dict("outer[inner]" => "value") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Deeply nested object" begin | ||
dict = Dict("a" => Dict("b" => Dict("c" => Dict("d" => "value")))) | ||
expected = Dict("a[b][c][d]" => "value") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Multiple nested objects" begin | ||
dict = Dict("a" => Dict("b" => "value1", "c" => "value2")) | ||
expected = Dict("a[b]" => "value1", "a[c]" => "value2") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Dictionary represented array" begin | ||
dict = Dict("a" => ["value1", "value2"]) | ||
expected = Dict("a[0]" => "value1", "a[1]" => "value2") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Mixed structure" begin | ||
dict = Dict("a" => Dict("b" => "value1", "c" => ["value2", "value3"])) | ||
expected = Dict("a[b]" => "value1", "a[c][0]" => "value2", "a[c][1]" => "value3") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
|
||
@testset "Blank values" begin | ||
dict = Dict("a" => Dict("b" => "", "c" => "")) | ||
expected = Dict("a[b]" => "", "a[c]" => "") | ||
@test serialize_to_query_dict(dict) == expected | ||
@test deep_object_serialize(dict) == expected | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters