MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_one

Method test_one

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

Source from the content-addressed store, hash-verified

1716 self.name = name
1717
1718 def test_one(self):
1719 child1, child2, child3, Parent, parent, Child1, Child2, Child3 = (
1720 self.tables.child1,
1721 self.tables.child2,
1722 self.tables.child3,
1723 self.classes.Parent,
1724 self.tables.parent,
1725 self.classes.Child1,
1726 self.classes.Child2,
1727 self.classes.Child3,
1728 )
1729
1730 self.mapper_registry.map_imperatively(
1731 Parent,
1732 parent,
1733 properties={
1734 "c1s": relationship(
1735 Child1, primaryjoin=child1.c.parent_id == parent.c.id
1736 ),
1737 "c2s": relationship(
1738 Child2, primaryjoin=child2.c.parent_id == parent.c.id
1739 ),
1740 "c3s": relationship(
1741 Child3, primaryjoin=child3.c.parent_id == parent.c.id
1742 ),
1743 "c1": relationship(
1744 Child1,
1745 primaryjoin=child1.c.id == parent.c.c1_id,
1746 post_update=True,
1747 ),
1748 "c2": relationship(
1749 Child2,
1750 primaryjoin=child2.c.id == parent.c.c2_id,
1751 post_update=True,
1752 ),
1753 "c3": relationship(
1754 Child3,
1755 primaryjoin=child3.c.id == parent.c.c3_id,
1756 post_update=True,
1757 ),
1758 },
1759 )
1760 self.mapper_registry.map_imperatively(Child1, child1)
1761 self.mapper_registry.map_imperatively(Child2, child2)
1762 self.mapper_registry.map_imperatively(Child3, child3)
1763
1764 sess = fixture_session()
1765
1766 p1 = Parent("p1")
1767 c11, c12, c13 = Child1("c1"), Child1("c2"), Child1("c3")
1768 c21, c22, c23 = Child2("c1"), Child2("c2"), Child2("c3")
1769 c31, c32, c33 = Child3("c1"), Child3("c2"), Child3("c3")
1770
1771 p1.c1s = [c11, c12, c13]
1772 p1.c2s = [c21, c22, c23]
1773 p1.c3s = [c31, c32, c33]
1774 sess.add(p1)
1775 sess.flush()

Callers

nothing calls this directly

Calls 11

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
CompiledSQLClass · 0.90
Child3Class · 0.85
map_imperativelyMethod · 0.80
assert_sql_executionMethod · 0.80
ParentClass · 0.70
Child1Class · 0.70
Child2Class · 0.70
addMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected