Пример #1
0
def test_query(records):
    person = Person.find_by(name='jjy')
    assert sorted(list(person.pets), key=lambda p: p.name) == sorted(list(Pet.where(person_id=person.id)),
                                                                     key=lambda p: p.name)
    assert person.pets.count() == 2
Пример #2
0
def test_find_by(persons):
    p = Person.where(name='jjy').first()
    assert p == Person.find_by(age=p.age)
    with pytest.raises(RecordNotFound):
        Person.find_by(name='A girl has no name')