MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_no_depth

Method test_no_depth

test/orm/test_eager_relations.py:4878–4923  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4876 )
4877
4878 def test_no_depth(self):
4879 nodes = self.tables.nodes
4880
4881 class Node(ComparableEntity):
4882 def append(self, node):
4883 self.children.append(node)
4884
4885 self.mapper_registry.map_imperatively(
4886 Node,
4887 nodes,
4888 properties={"children": relationship(Node, lazy="joined")},
4889 )
4890 sess = fixture_session()
4891 n1 = Node(data="n1")
4892 n1.append(Node(data="n11"))
4893 n1.append(Node(data="n12"))
4894 n1.append(Node(data="n13"))
4895 n1.children[1].append(Node(data="n121"))
4896 n1.children[1].append(Node(data="n122"))
4897 n1.children[1].append(Node(data="n123"))
4898 sess.add(n1)
4899 sess.flush()
4900 sess.expunge_all()
4901
4902 def go():
4903 d = sess.query(Node).filter_by(data="n1").first()
4904 eq_(
4905 Node(
4906 data="n1",
4907 children=[
4908 Node(data="n11"),
4909 Node(
4910 data="n12",
4911 children=[
4912 Node(data="n121"),
4913 Node(data="n122"),
4914 Node(data="n123"),
4915 ],
4916 ),
4917 Node(data="n13"),
4918 ],
4919 ),
4920 d,
4921 )
4922
4923 self.assert_sql_count(testing.db, go, 3)
4924
4925
4926class MixedSelfReferentialEagerTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 9

appendMethod · 0.95
relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
assert_sql_countMethod · 0.80
NodeClass · 0.70
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45

Tested by

no test coverage detected