def test_delete_all_records_in_repository(self, test_domain): """Delete all objects in a repository""" test_domain.get_dao(Person).create(id=1, first_name='Athos', last_name='Musketeer', age=2) test_domain.get_dao(Person).create(id=2, first_name='Porthos', last_name='Musketeer', age=3) test_domain.get_dao(Person).create(id=3, first_name='Aramis', last_name='Musketeer', age=4) test_domain.get_dao(Person).create(id=4, first_name='dArtagnan', last_name='Musketeer', age=5) person_records = test_domain.get_dao(Person).query.filter(Q()) assert person_records.total == 4 test_domain.get_dao(Person).delete_all() person_records = test_domain.get_dao(Person).query.filter(Q()) assert person_records.total == 0
def test_deconstruct_and(self): q1 = Q(price__gt=10.0) q2 = Q(price=11.0) q = q1 & q2 path, args, kwargs = q.deconstruct() assert args == ( ("price__gt", 10.0), ("price", 11.0), ) assert kwargs == {}
def test_deconstruct_or(self): q1 = Q(price__gt=10.0) q2 = Q(price=11.0) q3 = q1 | q2 path, args, kwargs = q3.deconstruct() assert args == ( ("price__gt", 10.0), ("price", 11.0), ) assert kwargs == {"_connector": "OR"}
def test_deconstruct_or(self): q1 = Q(price__gt=10.0) q2 = Q(price=11.0) q3 = q1 | q2 path, args, kwargs = q3.deconstruct() assert args == ( ('price__gt', 10.0), ('price', 11.0), ) assert kwargs == {'_connector': 'OR'}
def test_deconstruct_multiple_kwargs(self): q = Q(price__gt=10.0, price=11.0) path, args, kwargs = q.deconstruct() assert args == ( ("price", 11.0), ("price__gt", 10.0), ) assert kwargs == {}
def test_deconstruct_negated(self): q = ~Q(price__gt=10.0) path, args, kwargs = q.deconstruct() assert args == () assert kwargs == { "price__gt": 10.0, "_negated": True, }
def test_deconstruct_negated(self): q = ~Q(price__gt=10.0) path, args, kwargs = q.deconstruct() assert args == () assert kwargs == { 'price__gt': 10.0, '_negated': True, }
def test_delete_all_records_in_repository(self, test_domain): """Delete all objects in a repository""" test_domain.get_dao(Person).create(first_name="Athos", last_name="Musketeer", age=2) test_domain.get_dao(Person).create(first_name="Porthos", last_name="Musketeer", age=3) test_domain.get_dao(Person).create(first_name="Aramis", last_name="Musketeer", age=4) test_domain.get_dao(Person).create(first_name="dArtagnan", last_name="Musketeer", age=5) person_records = test_domain.get_dao(Person).query.filter(Q()) assert person_records.total == 4 test_domain.get_dao(Person).delete_all() person_records = test_domain.get_dao(Person).query.filter(Q()) assert person_records.total == 0
def test_reconstruct_and(self): q1 = Q(price__gt=10.0) q2 = Q(price=11.0) q = q1 & q2 path, args, kwargs = q.deconstruct() assert Q(*args, **kwargs) == q
def test_deconstruct(self): q = Q(price__gt=10.0) path, args, kwargs = q.deconstruct() assert path == "protean.utils.query.Q" assert args == () assert kwargs == {"price__gt": 10.0}
def test_reconstruct_negated(self): q = ~Q(price__gt=10.0) path, args, kwargs = q.deconstruct() assert Q(*args, **kwargs) == q