MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cycle

Method test_cycle

test/orm/test_cycles.py:133–165  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

131 assert c2.parent_c1 == c1.c1
132
133 def test_cycle(self):
134 C2, C1, t2, t1 = (
135 self.classes.C2,
136 self.classes.C1,
137 self.tables.t2,
138 self.tables.t1,
139 )
140
141 self.mapper_registry.map_imperatively(
142 C1,
143 t1,
144 properties={
145 "c1s": relationship(C1, cascade="all"),
146 "c2s": relationship(
147 self.mapper_registry.map_imperatively(C2, t2),
148 cascade="all, delete-orphan",
149 ),
150 },
151 )
152
153 a = C1("head c1")
154 a.c1s.append(C1("child1"))
155 a.c1s.append(C1("child2"))
156 a.c1s[0].c1s.append(C1("subchild1"))
157 a.c1s[0].c1s.append(C1("subchild2"))
158 a.c1s[1].c2s.append(C2("child2 data1"))
159 a.c1s[1].c2s.append(C2("child2 data2"))
160 sess = fixture_session()
161 sess.add(a)
162 sess.flush()
163
164 sess.delete(a)
165 sess.flush()
166
167 def test_setnull_ondelete(self):
168 C1, t1 = self.classes.C1, self.tables.t1

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
C1Class · 0.70
C2Class · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected