MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_many_to_one_only

Method test_many_to_one_only

test/orm/test_cycles.py:328–350  ·  view source on GitHub ↗

test similar to SelfReferentialTest.testmanytooneonly

(self)

Source from the content-addressed store, hash-verified

326 )
327
328 def test_many_to_one_only(self):
329 """test similar to SelfReferentialTest.testmanytooneonly"""
330
331 Child1, Child2 = self.classes.Child1, self.classes.Child2
332
333 session = fixture_session()
334
335 c1 = Child1()
336 c1.child1_data = "qwerty"
337 session.add(c1)
338 session.flush()
339 session.expunge_all()
340
341 c1 = session.query(Child1).filter_by(child1_data="qwerty").one()
342 c2 = Child2()
343 c2.child1 = c1
344 c2.child2_data = "asdfgh"
345 session.add(c2)
346
347 # the flush will fail if the UOW does not set up a many-to-one DP
348 # attached to a task corresponding to c1, since "child1_id" is not
349 # nullable
350 session.flush()
351
352
353class InheritTestTwo(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 9

fixture_sessionFunction · 0.90
Child1Class · 0.70
Child2Class · 0.70
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45
oneMethod · 0.45
filter_byMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected