示例#1
0
def test_get_query_failure():
    """
    Filters does not produce a query if any of the keys are not known
    """
    vals = {"this_key_does_not_exist": 123}
    filters = Filters(vals)

    with pytest.raises(FilterError):
        filters.getQuery()
示例#2
0
def test_get_query_remaining(key):
    """
    Some fields are simply copied to the query as-is
    """
    vals = {key: "some-value"}
    filters = Filters(vals)
    query = filters.getQuery()
    assert query[key] == "some-value"
示例#3
0
def test_get_query_not_subscribed(key):
    """
    Unsubscribed is treated the same way as unknown: it is omitted from the query
    """
    vals = {key: False}
    filters = Filters(vals)
    query = filters.getQuery()
    assert key not in query
示例#4
0
def test_get_query_subscribed(key):
    """
    Subscription status is included when it is in the affirmative
    """
    vals = {key: True}
    filters = Filters(vals)
    query = filters.getQuery()
    assert query[key] is True
示例#5
0
def test_get_query_multi_state():
    """
    Multiple states should be added to the query as a comma-separated list, enclosed by parentheses
    """
    vals = {"state_cd": ["AZ", "WY"]}
    filters = Filters(vals)
    query = filters.getQuery()
    assert query["state_cd"] == "(AZ,WY)"
示例#6
0
def test_get_query_single_state(state_cd):
    """
    A single state_cd should be added to the query as-is
    """
    vals = {"state_cd": state_cd}
    filters = Filters(vals)
    query = filters.getQuery()
    assert query["state_cd"] == "AZ"