MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _setup

Method _setup

test/ext/test_orderinglist.py:68–123  ·  test/ext/test_orderinglist.py::OrderingListTest._setup

Build a relationship situation using the given test_collection_class factory

(self, test_collection_class)

Source from the content-addressed store, hash-verified

66 metadata = MetaData()
67
68 def _setup(self, test_collection_class):
69 class="st">"""Build a relationship situation using the given
70 test_collection_class factoryclass="st">"""
71
72 global slides_table, bullets_table, Slide, Bullet
73
74 slides_table = Table(
75 class="st">"test_Slides",
76 metadata,
77 Column(
78 class="st">"id", Integer, primary_key=True, test_needs_autoincrement=True
79 ),
80 Column(class="st">"name", String(128)),
81 )
82 bullets_table = Table(
83 class="st">"test_Bullets",
84 metadata,
85 Column(
86 class="st">"id", Integer, primary_key=True, test_needs_autoincrement=True
87 ),
88 Column(class="st">"slide_id", Integer, ForeignKey(class="st">"test_Slides.id")),
89 Column(class="st">"position", Integer),
90 Column(class="st">"text", String(128)),
91 )
92
93 class Slide:
94 def __init__(self, name):
95 self.name = name
96
97 def __repr__(self):
98 return &class="cm">#x27;<Slide class="st">"%s">' % self.name
99
100 class Bullet:
101 def __init__(self, text):
102 self.text = text
103
104 def __repr__(self):
105 return &class="cm">#x27;<Bullet class="st">"%s" pos %s>' % (self.text, self.position)
106
107 clear_mappers()
108 self.mapper_registry.map_imperatively(
109 Slide,
110 slides_table,
111 properties={
112 class="st">"bullets": relationship(
113 Bullet,
114 lazy=class="st">"joined",
115 collection_class=test_collection_class,
116 backref=class="st">"slide",
117 order_by=[bullets_table.c.position],
118 )
119 },
120 )
121 self.mapper_registry.map_imperatively(Bullet, bullets_table)
122
123 metadata.create_all(testing.db)
124
125 def teardown_test(self):

Callers 7

test_append_reorderMethod · 0.95
test_insertMethod · 0.95
test_sliceMethod · 0.95
test_replaceMethod · 0.95
test_replace_twoMethod · 0.95
_run_testMethod · 0.80

Calls 8

TableClass · 0.90
ColumnClass · 0.90
StringClass · 0.90
ForeignKeyClass · 0.90
clear_mappersFunction · 0.90
relationshipFunction · 0.90
map_imperativelyMethod · 0.80
create_allMethod · 0.80

Tested by

no test coverage detected