Beispiel #1
0
def test_transform(site):
    """Test that simple transform function work"""
    mapping = {"fname": func.slice("first_aps.name", [2,4])}
    results = list(site.view("second_ap", aliases=mapping))
    eq_(len(results), 4)
    assert all((len(res['fname']) == 2 for res in results))
    results = list(site.view("first_ap",
        request={"id": 4},
        aliases={"second_ap_name": func.coalesce("second_ap.name", "(Empty)"),
            'round': func.round(func.constant(0.9))}))
    eq_(len(results), 1)
    eq_(results[0]['second_ap_name'], '(Empty)')
    eq_(results[0]['round'], 1)
Beispiel #2
0
def test_view_transform(site):
    """Test the select with a transfrom"""
    results = list(site.view("things", {"foo": func.slice("name", [1,3])}))
    eq_(len(results), 3)
    eq_(set(item["foo"] for item in results), set(["oo", "ar"]))