MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_basic

Method test_basic

test/orm/test_unitofwork.py:446–485  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

444 pass
445
446 def test_basic(self):
447 peoplesites, PersonSite, Person, people = (
448 self.tables.peoplesites,
449 self.classes.PersonSite,
450 self.classes.Person,
451 self.tables.people,
452 )
453
454 self.mapper_registry.map_imperatively(PersonSite, peoplesites)
455 m2 = self.mapper_registry.map_imperatively(
456 Person, people, properties={"sites": relationship(PersonSite)}
457 )
458
459 sa.orm.configure_mappers()
460 eq_(
461 list(m2.get_property("sites").synchronize_pairs),
462 [(people.c.person, peoplesites.c.person)],
463 )
464
465 p = Person(person="im the key", firstname="asdf")
466 ps = PersonSite(site="asdf")
467 p.sites.append(ps)
468
469 session = fixture_session()
470 session.add(p)
471 session.flush()
472
473 conn = session.connection()
474 p_count = conn.scalar(
475 select(func.count("*")).where(people.c.person == "im the key")
476 )
477 eq_(p_count, 1)
478 eq_(
479 conn.scalar(
480 select(func.count("*")).where(
481 peoplesites.c.person == "im the key"
482 )
483 ),
484 1,
485 )
486
487
488class ClauseAttributesTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 15

relationshipFunction · 0.90
eq_Function · 0.90
fixture_sessionFunction · 0.90
selectFunction · 0.90
PersonSiteClass · 0.85
map_imperativelyMethod · 0.80
get_propertyMethod · 0.80
PersonClass · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
connectionMethod · 0.45

Tested by

no test coverage detected