예제 #1
0
def test_query_dict_items():
    d = models.QueryDict(_default_query)

    items = d.items()
    assert inspect.isgenerator(items)
    assert dict(items) == {
        "q": "{ hello }",
        "name": "myname",
        "user_name": "test_user"
    }
예제 #2
0
def test_query_dict_items_list():
    d = models.QueryDict(_default_query)

    items_list = d.items_list()
    assert inspect.isgenerator(items_list)
    assert dict(items_list) == {
        "q": ["{ hello }"],
        "name": ["myname"],
        "user_name": ["test_user"],
    }
예제 #3
0
def test_query_dict_get():
    d = models.QueryDict(_default_query)

    assert d["user_name"] == "test_user"
    assert d.get("key_none_exist") is None
예제 #4
0
def test_query_dict_get_list():
    d = models.QueryDict(_default_query)

    assert d.get_list("user_name") == ["test_user"]
    assert d.get_list("key_none_exist") == []
    assert d.get_list("key_none_exist", ["foo"]) == ["foo"]
예제 #5
0
def test_query_dict(query, expected):
    d = models.QueryDict(query)
    assert d == expected