Пример #1
0
def test_two_templates_as_dict_with_one_match_no_server_side_filters():
    """
    Assert that client-side filtering works; the gRPC Ledger API does not support any server-side
    filtering of contracts beyond template names, so filtering must be done on the client in this
    case.
    """
    actual = parse_query(
        {
            "SuperCool:Tmpl": {
                "field": 42
            },
            "ReallyCool:Tmpl": None
        },
        server_side_filters=False)

    assert actual is not None
    assert actual[SuperCoolTmpl].server_side is None

    # A contract with a "field" value of 42 should match the client-side filter
    assert actual[SuperCoolTmpl].client_side({"field": 42})

    # A contract with a "field" value of 43 should NOT match the client-side filter
    assert not actual[SuperCoolTmpl].client_side({"field": 43})

    assert actual[ReallyCoolTmpl] == EMPTY
Пример #2
0
def test_two_templates_as_dict_with_one_match_server_side_filters():
    expected = {
        SuperCoolTmpl: Filter(server_side={"field": 42}),
        ReallyCoolTmpl: EMPTY
    }
    actual = parse_query(
        {
            "SuperCool:Tmpl": {
                "field": 42
            },
            "ReallyCool:Tmpl": None
        },
        server_side_filters=True)

    assert expected == actual
Пример #3
0
def test_empty_query(server_side_filters):
    actual = parse_query(server_side_filters=server_side_filters)
    assert actual is None
Пример #4
0
def test_two_templates(queries, server_side_filters):
    expected = {SuperCoolTmpl: EMPTY, ReallyCoolTmpl: EMPTY}
    actual = parse_query(*queries, server_side_filters=server_side_filters)

    assert expected == actual
Пример #5
0
def test_single_template(server_side_filters):
    expected = {SuperCoolTmpl: EMPTY}
    actual = parse_query("SuperCool:Tmpl",
                         server_side_filters=server_side_filters)

    assert expected == actual