Beispiel #1
0
def test_parse_bool_arguments():
    # test that bool args are matched, even if follwed by a comma
    # ordering issues in earlier python versions
    inner = OrderedDict()
    inner["x"] = True
    inner["y"] = False

    args = parse_graphql_arguments({"where": inner})
    assert args == "where: { x: true, y: false }"
Beispiel #2
0
def test_parse_none_arguments():
    # test that nulls are matched, even when followed by a comma

    # ordering issues in earlier python versions
    inner = OrderedDict()
    inner["x"] = None
    inner["y"] = None
    args = parse_graphql_arguments({"where": inner})
    assert args == "where: { x: null, y: null }"
Beispiel #3
0
def test_parse_nested_string():
    gql_args = parse_graphql_arguments(
        {"input": {
            "x": json.dumps({
                "a": 1,
                "b": 2
            }, sort_keys=True)
        }})
    assert gql_args == r'input: { x: "{\"a\": 1, \"b\": 2}" }'
Beispiel #4
0
def test_parse_json_arguments():
    arg = json.dumps({"a": "b", "c": [1, "d"]}, sort_keys=True)
    gql_args = parse_graphql_arguments({"where": {"x": {"eq": arg}}})
    assert gql_args == r'where: { x: { eq: "{\"a\": \"b\", \"c\": [1, \"d\"]}" } }'
Beispiel #5
0
def test_parse_string_arguments():
    args = parse_graphql_arguments({"where": {"x": {"eq": r"a 'b' c"}}})
    assert args == "where: { x: { eq: \"a 'b' c\" } }"
Beispiel #6
0
def test_parse_arguments():
    args = parse_graphql_arguments({"where": {"x": {"eq": "1"}}})
    assert args == 'where: { x: { eq: "1" } }'
Beispiel #7
0
def test_uuid_value_in_arguments():
    id = uuid.uuid4()
    query = parse_graphql_arguments({"id": id})
    assert query == 'id: "{}"'.format(id)
Beispiel #8
0
def test_set_value_in_arguments_with_one_value():
    query = parse_graphql_arguments(
        {"where": {
            "color": LiteralSetValue(["red"])
        }})
    assert query == 'where: { color: "{red}" }'
Beispiel #9
0
def test_enum_value_in_arguments():
    query = parse_graphql_arguments({"where": {"color": EnumValue("red")}})
    assert query == "where: { color: red }"
Beispiel #10
0
def test_dict_values_in_arguments():
    x = {"a": 1, "b": 2}
    assert parse_graphql_arguments({"checks": x.values()}) in [
        "checks: [1, 2]",
        "checks: [2, 1]",
    ]
Beispiel #11
0
def test_dict_keys_in_arguments():
    x = {"a": 1, "b": 2}
    assert parse_graphql_arguments({"checks": x.keys()}) in [
        'checks: ["a", "b"]',
        'checks: ["b", "a"]',
    ]
Beispiel #12
0
def test_empty_dict_in_arguments():
    assert parse_graphql_arguments({"where": {}}) == "where: {}"