def test_flask_sqla_compat(): # test djrobstep#18 for regression class T(declarative_base()): __tablename__ = "t" i = Column(Integer, primary_key=True) desc = { "name": "T", "type": T, "aliased": False, "expr": class_mapper(T), "entity": T, } mapping = derive_order_key(OC(T.i), desc, 0) assert isinstance(mapping, AttributeColumn)
def test_flask_sqla_compat(): # test djrobstep#18 for regression class T(declarative_base()): __tablename__ = 't' i = Column(Integer, primary_key=True) desc = { 'name': 'T', 'type': T, 'aliased': False, 'expr': class_mapper(T), 'entity': T, } mapping = derive_order_key(OC(T.i), desc, 0) assert isinstance(mapping, AttributeColumn)
def test_paging_object2_per_page_3(): ob = [OC(x) for x in ["id", "b"]] p = Paging(T2, 3, ob, backwards=False, current_marker=None, get_marker=getitem) assert p.next == ((3, 3), False) assert not p.has_next assert not p.has_previous assert p.further == ((3, 3), False) assert p.previous == ((1, 2), True) assert p.is_full general_asserts(p)
def test_core(dburl): spec = ["b", "d", "book_id", "c"] cols = [column(each) for each in spec] ob = [OC(x).uo for x in spec] selectable = select( cols, from_obj=[table("t_Book")], whereclause=column("d") == 99, order_by=ob ) with S(dburl, echo=ECHO) as s: check_paging_core(selectable=selectable, s=s) # Check again with a connection instead of session (see #37): with S(dburl, echo=ECHO) as s: check_paging_core(selectable=selectable, s=s.connection())
def test_paging_object2_per_page_2(): ob = [OC(x) for x in ['id', 'b']] p = Paging(T2, 2, ob, backwards=False, current_marker=None, get_marker=getitem) assert p.next == ((2, 1), False) assert p.has_next general_asserts(p) assert not p.has_previous assert p.previous == ((1, 2), True) assert p.further == ((2, 1), False) general_asserts(p)
def test_paging_objects1(): p = Page(["abc"]) assert p.one() == "abc" with raises(RuntimeError): Page([1, 2]).one() with raises(RuntimeError): Page([]).one() ob = [OC(x) for x in ["id", "b"]] p = Paging(T1, 10, ob, backwards=False, current_marker=None, get_marker=getitem) assert p.next == (None, False) assert p.further == (None, False) assert p.previous == (None, True) assert not p.is_full general_asserts(p)