MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_stale_conditions

Method test_stale_conditions

test/orm/test_manytomany.py:358–408  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

356 @testing.requires.updateable_autoincrement_pks
357 @testing.requires.sane_multi_rowcount
358 def test_stale_conditions(self):
359 Place, Transition, place_input, place, transition = (
360 self.classes.Place,
361 self.classes.Transition,
362 self.tables.place_input,
363 self.tables.place,
364 self.tables.transition,
365 )
366
367 self.mapper_registry.map_imperatively(
368 Place,
369 place,
370 properties={
371 "transitions": relationship(
372 Transition, secondary=place_input, passive_updates=False
373 )
374 },
375 )
376 self.mapper_registry.map_imperatively(Transition, transition)
377
378 p1 = Place("place1")
379 t1 = Transition("t1")
380 p1.transitions.append(t1)
381 sess = fixture_session()
382 sess.add_all([p1, t1])
383 sess.commit()
384
385 p1.place_id
386 p1.transitions
387
388 sess.execute(place_input.delete())
389 p1.place_id = 7
390
391 assert_raises_message(
392 orm_exc.StaleDataError,
393 r"UPDATE statement on table 'place_input' expected to "
394 r"update 1 row\(s\); Only 0 were matched.",
395 sess.commit,
396 )
397 sess.rollback()
398
399 p1.place_id
400 p1.transitions
401 sess.execute(place_input.delete())
402 p1.transitions.remove(t1)
403 assert_raises_message(
404 orm_exc.StaleDataError,
405 r"DELETE statement on table 'place_input' expected to "
406 r"delete 1 row\(s\); Only 0 were matched.",
407 sess.commit,
408 )
409
410
411class AssortedPersistenceTests(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 13

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
assert_raises_messageFunction · 0.90
PlaceClass · 0.85
TransitionClass · 0.85
map_imperativelyMethod · 0.80
appendMethod · 0.45
add_allMethod · 0.45
commitMethod · 0.45
executeMethod · 0.45
deleteMethod · 0.45
rollbackMethod · 0.45

Tested by

no test coverage detected