MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_misc_one

Method test_misc_one

test/orm/test_compile.py:191–235  ·  view source on GitHub ↗
(self, connection, metadata)

Source from the content-addressed store, hash-verified

189 )
190
191 def test_misc_one(self, connection, metadata):
192 node_table = Table(
193 "node",
194 metadata,
195 Column("node_id", Integer, primary_key=True),
196 Column("name_index", Integer, nullable=True),
197 )
198 node_name_table = Table(
199 "node_name",
200 metadata,
201 Column("node_name_id", Integer, primary_key=True),
202 Column("node_id", Integer, ForeignKey("node.node_id")),
203 Column("host_id", Integer, ForeignKey("host.host_id")),
204 Column("name", String(64), nullable=False),
205 )
206 host_table = Table(
207 "host",
208 metadata,
209 Column("host_id", Integer, primary_key=True),
210 Column("hostname", String(64), nullable=False, unique=True),
211 )
212 metadata.create_all(connection)
213 connection.execute(node_table.insert(), dict(node_id=1, node_index=5))
214
215 class Node:
216 pass
217
218 class NodeName:
219 pass
220
221 class Host:
222 pass
223
224 self.mapper_registry.map_imperatively(Node, node_table)
225 self.mapper_registry.map_imperatively(Host, host_table)
226 self.mapper_registry.map_imperatively(
227 NodeName,
228 node_name_table,
229 properties={
230 "node": relationship(Node, backref=backref("names")),
231 "host": relationship(Host),
232 },
233 )
234 sess = Session(connection)
235 assert sess.get(Node, 1).names == []
236
237 def test_conflicting_backref_two(self):
238 meta = MetaData()

Callers

nothing calls this directly

Calls 12

getMethod · 0.95
TableClass · 0.90
ColumnClass · 0.90
ForeignKeyClass · 0.90
StringClass · 0.90
relationshipFunction · 0.90
backrefFunction · 0.90
SessionClass · 0.90
create_allMethod · 0.80
map_imperativelyMethod · 0.80
executeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected