MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_bidirectional

Method test_bidirectional

test/orm/test_manytomany.py:287–354  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

285 )
286
287 def test_bidirectional(self):
288 place_input, transition, Transition, Place, place, place_output = (
289 self.tables.place_input,
290 self.tables.transition,
291 self.classes.Transition,
292 self.classes.Place,
293 self.tables.place,
294 self.tables.place_output,
295 )
296
297 self.mapper_registry.map_imperatively(Place, place)
298 self.mapper_registry.map_imperatively(
299 Transition,
300 transition,
301 properties=dict(
302 inputs=relationship(
303 Place,
304 place_output,
305 backref=backref(
306 "inputs", order_by=transition.c.transition_id
307 ),
308 order_by=Place.place_id,
309 ),
310 outputs=relationship(
311 Place,
312 place_input,
313 backref=backref(
314 "outputs", order_by=transition.c.transition_id
315 ),
316 order_by=Place.place_id,
317 ),
318 ),
319 )
320
321 t1 = Transition("transition1")
322 t2 = Transition("transition2")
323 t3 = Transition("transition3")
324 p1 = Place("place1")
325 p2 = Place("place2")
326 p3 = Place("place3")
327
328 sess = fixture_session()
329 sess.add_all([p3, p1, t1, t2, p2, t3])
330
331 t1.inputs.append(p1)
332 t1.inputs.append(p2)
333 t1.outputs.append(p3)
334 t2.inputs.append(p1)
335 p2.inputs.append(t2)
336 p3.inputs.append(t2)
337 p1.outputs.append(t1)
338 sess.commit()
339
340 self.assert_result(
341 [t1],
342 Transition,
343 {"outputs": (Place, [{"name": "place3"}, {"name": "place1"}])},
344 )

Callers

nothing calls this directly

Calls 10

relationshipFunction · 0.90
backrefFunction · 0.90
fixture_sessionFunction · 0.90
TransitionClass · 0.85
PlaceClass · 0.85
map_imperativelyMethod · 0.80
assert_resultMethod · 0.80
add_allMethod · 0.45
appendMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected