MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_empty_scalars

Method test_empty_scalars

test/ext/test_associationproxy.py:1225–1270  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1223
1224 @testing.provide_metadata
1225 def test_empty_scalars(self):
1226 metadata = self.metadata
1227
1228 a = Table(
1229 "a",
1230 metadata,
1231 Column("id", Integer, primary_key=True),
1232 Column("name", String(50)),
1233 )
1234 a2b = Table(
1235 "a2b",
1236 metadata,
1237 Column("id", Integer, primary_key=True),
1238 Column("id_a", Integer, ForeignKey("a.id")),
1239 Column("id_b", Integer, ForeignKey("b.id")),
1240 Column("name", String(50)),
1241 )
1242 b = Table(
1243 "b",
1244 metadata,
1245 Column("id", Integer, primary_key=True),
1246 Column("name", String(50)),
1247 )
1248
1249 class A:
1250 a2b_name = association_proxy("a2b_single", "name")
1251 b_single = association_proxy("a2b_single", "b")
1252
1253 class A2B:
1254 pass
1255
1256 class B:
1257 pass
1258
1259 self.mapper_registry.map_imperatively(
1260 A, a, properties=dict(a2b_single=relationship(A2B, uselist=False))
1261 )
1262
1263 self.mapper_registry.map_imperatively(
1264 A2B, a2b, properties=dict(b=relationship(B))
1265 )
1266 self.mapper_registry.map_imperatively(B, b)
1267
1268 a1 = A()
1269 assert a1.a2b_name is None
1270 assert a1.b_single is None
1271
1272 def test_custom_getset(self):
1273 metadata = MetaData()

Callers

nothing calls this directly

Calls 7

TableClass · 0.90
ColumnClass · 0.90
StringClass · 0.90
ForeignKeyClass · 0.90
relationshipFunction · 0.90
map_imperativelyMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected