MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_one

Method test_one

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

Source from the content-addressed store, hash-verified

1535 self.name = name
1536
1537 def test_one(self):
1538 Child, Parent, parent, child = (
1539 self.classes.Child,
1540 self.classes.Parent,
1541 self.tables.parent,
1542 self.tables.child,
1543 )
1544
1545 self.mapper_registry.map_imperatively(
1546 Parent,
1547 parent,
1548 properties={
1549 "children": relationship(
1550 Child, primaryjoin=parent.c.id == child.c.parent_id
1551 ),
1552 "child": relationship(
1553 Child,
1554 primaryjoin=parent.c.child_id == child.c.id,
1555 post_update=True,
1556 ),
1557 },
1558 )
1559 self.mapper_registry.map_imperatively(
1560 Child,
1561 child,
1562 properties={"parent": relationship(Child, remote_side=child.c.id)},
1563 )
1564
1565 session = fixture_session()
1566 p1 = Parent("p1")
1567 c1 = Child("c1")
1568 c2 = Child("c2")
1569 p1.children = [c1, c2]
1570 c2.parent = c1
1571 p1.child = c2
1572
1573 session.add_all([p1, c1, c2])
1574 session.flush()
1575
1576 p2 = Parent("p2")
1577 c3 = Child("c3")
1578 p2.children = [c3]
1579 p2.child = c3
1580 session.add(p2)
1581
1582 session.delete(c2)
1583 p1.children.remove(c2)
1584 p1.child = None
1585 session.flush()
1586
1587 p2.child = None
1588 session.flush()
1589
1590
1591class PostUpdatePrefetchTest(fixtures.DeclarativeMappedTest):

Callers

nothing calls this directly

Calls 10

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
ParentClass · 0.70
ChildClass · 0.70
add_allMethod · 0.45
flushMethod · 0.45
addMethod · 0.45
deleteMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected