| 1 |
|
| 2 |
|
| 3 |
from auth0.management.core.query_encoder import encode_query |
| 4 |
|
| 5 |
|
| 6 |
def test_query_encoding_deep_objects() -> None: |
| 7 |
assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] |
| 8 |
assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] |
| 9 |
assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ |
| 10 |
("hello_world[hello][world]", "today"), |
| 11 |
("hello_world[test]", "this"), |
| 12 |
("hi", "there"), |
| 13 |
] |
| 14 |
|
| 15 |
|
| 16 |
def test_query_encoding_deep_object_arrays() -> None: |
| 17 |
assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ |
| 18 |
("objects[key]", "hello"), |
| 19 |
("objects[value]", "world"), |
| 20 |
("objects[key]", "foo"), |
| 21 |
("objects[value]", "bar"), |
| 22 |
] |
| 23 |
assert encode_query( |
| 24 |
{"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} |
| 25 |
) == [ |
| 26 |
("users[name]", "string"), |
| 27 |
("users[tags]", "string"), |
| 28 |
("users[name]", "string2"), |
| 29 |
("users[tags]", "string2"), |
| 30 |
("users[tags]", "string3"), |
| 31 |
] |
| 32 |
|
| 33 |
|
| 34 |
def test_encode_query_with_none() -> None: |
| 35 |
encoded = encode_query(None) |
| 36 |
assert encoded is None |