| 1 |
from graphql.pyutils import Path |
| 2 |
|
| 3 |
|
| 4 |
def describe_path(): |
| 5 |
def can_create_a_path(): |
| 6 |
first = Path(None, 1, "First") |
| 7 |
assert first.prev is None |
| 8 |
assert first.key == 1 |
| 9 |
assert first.typename == "First" |
| 10 |
|
| 11 |
def can_add_a_new_key_to_an_existing_path(): |
| 12 |
first = Path(None, 1, "First") |
| 13 |
second = first.add_key("two", "Second") |
| 14 |
assert second.prev is first |
| 15 |
assert second.key == "two" |
| 16 |
assert second.typename == "Second" |
| 17 |
|
| 18 |
def can_convert_a_path_to_a_list_of_its_keys(): |
| 19 |
root = Path(None, 0, "Root") |
| 20 |
assert root.as_list() == [0] |
| 21 |
first = root.add_key("one", "First") |
| 22 |
assert first.as_list() == [0, "one"] |
| 23 |
second = first.add_key(2, "Second") |
| 24 |
assert second.as_list() == [0, "one", 2] |