Ejemplo n.º 1
0
def test_all_with_order_reversed():
    rv = _addresses.create(json="""
        [
            {
                "property_name": "1 name",
                "postcode": "N2 2NN"
            },
            {
                "property_name": "3 name",
                "postcode": "N2 2NN"
            },
            {
                "property_name": "2 name",
                "postcode": "N2 2NN"
            }
        ]
    """)
    assert rv is not None
    a = _addresses.first(property_name='1 name')
    b = _addresses.first(property_name='2 name')
    c = _addresses.first(property_name='3 name')
    assert a is not None
    assert b is not None
    assert c is not None
    rv2 = _addresses.all(order_by=">property_name")
    assert rv2[0].id == c.id
    assert rv2[1].id == b.id
    assert rv2[2].id == a.id
Ejemplo n.º 2
0
def test_all_with_limit():
    rv = _addresses.create(json="""
        [
            {
                "property_name": "1 name",
                "postcode": "N2 2NN"
            },
            {
                "property_name": "3 name",
                "postcode": "N2 2NN"
            },
            {
                "property_name": "2 name",
                "postcode": "N2 2NN"
            }
        ]
    """)
    assert rv is not None
    a = _addresses.first(property_name='1 name')
    b = _addresses.first(property_name='2 name')
    c = _addresses.first(property_name='3 name')
    assert a is not None
    assert b is not None
    assert c is not None
    rv2 = _addresses.all(limit=1)
    assert rv2 is not None
    rv3 = _addresses.all(limit=2)
    assert len(rv3) == 2
Ejemplo n.º 3
0
def test_create_multiple_from_json():
    a = _addresses.create(json="""
        [
            {
                "postcode": "N2 2NN"
            },
            {
                "postcode": "N3 3NN"
            }
        ]
    """)
    assert a is not None
    b = _addresses.first(postcode='N2 2NN')
    c = _addresses.first(postcode='N3 3NN')
    assert b is not None
    assert c is not None
Ejemplo n.º 4
0
def test_create_from_json():
    a = _addresses.create(json="""
        {
            "postcode": "N2 2NN"
        }
    """)
    assert a is not None
    b = _addresses.first(postcode='N2 2NN')
    assert b is not None
Ejemplo n.º 5
0
def test_get_or_create():
    a = _addresses.first(postcode='N1 1NN')
    assert a is None
    b = _addresses.get_or_create(postcode='N1 1NN')
    assert b is not None
    rv = _addresses.find(postcode='N1 1NN')
    assert len(rv) == 1
    # c should return the address created in b
    c = _addresses.get_or_create(postcode='N1 1NN')
    assert c is not None
    rv2 = _addresses.find(postcode='N1 1NN')
    assert len(rv2) == 1
Ejemplo n.º 6
0
def test_create():
    a = _addresses.create(postcode='N1 1NN')
    assert a is not None
    b = _addresses.first(postcode='N1 1NN')
    assert b is not None