MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_replace

Method test_replace

test/ext/test_orderinglist.py:359–393  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

357 self.assert_(srt.bullets[i].text == text)
358
359 def test_replace(self):
360 self._setup(ordering_list("position"))
361
362 s1 = Slide("Slide #1")
363 s1.bullets = [Bullet("1"), Bullet("2"), Bullet("3")]
364
365 self.assert_(len(s1.bullets) == 3)
366 self.assert_(s1.bullets[2].position == 2)
367
368 session = fixture_session()
369 session.add(s1)
370 session.flush()
371
372 new_bullet = Bullet("new 2")
373 self.assert_(new_bullet.position is None)
374
375 # mark existing bullet as db-deleted before replacement.
376 # session.delete(s1.bullets[1])
377 s1.bullets[1] = new_bullet
378
379 self.assert_(new_bullet.position == 1)
380 self.assert_(len(s1.bullets) == 3)
381
382 id_ = s1.id
383
384 session.flush()
385 session.expunge_all()
386
387 srt = session.get(Slide, id_)
388
389 self.assert_(srt.bullets)
390 self.assert_(len(srt.bullets) == 3)
391
392 self.assert_(srt.bullets[1].text == "new 2")
393 self.assert_(srt.bullets[2].text == "3")
394
395 def test_replace_two(self):
396 """test #3191"""

Callers

nothing calls this directly

Calls 10

_setupMethod · 0.95
ordering_listFunction · 0.90
fixture_sessionFunction · 0.90
SlideClass · 0.70
BulletClass · 0.70
assert_Method · 0.45
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected