MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_insert

Method test_insert

test/ext/test_orderinglist.py:262–308  ·  test/ext/test_orderinglist.py::OrderingListTest.test_insert
(self)

Source from the content-addressed store, hash-verified

260 eq_(titles, found)
261
262 def test_insert(self):
263 self._setup(ordering_list(class="st">"position"))
264
265 s1 = Slide(class="st">"Slide class="cm">#1")
266 s1.bullets.append(Bullet(class="st">"1"))
267 s1.bullets.append(Bullet(class="st">"2"))
268 s1.bullets.append(Bullet(class="st">"3"))
269 s1.bullets.append(Bullet(class="st">"4"))
270
271 self.assert_(s1.bullets[0].position == 0)
272 self.assert_(s1.bullets[1].position == 1)
273 self.assert_(s1.bullets[2].position == 2)
274 self.assert_(s1.bullets[3].position == 3)
275
276 s1.bullets.insert(2, Bullet(class="st">"insert_at_2"))
277 self.assert_(s1.bullets[0].position == 0)
278 self.assert_(s1.bullets[1].position == 1)
279 self.assert_(s1.bullets[2].position == 2)
280 self.assert_(s1.bullets[3].position == 3)
281 self.assert_(s1.bullets[4].position == 4)
282
283 self.assert_(s1.bullets[1].text == class="st">"2")
284 self.assert_(s1.bullets[2].text == class="st">"insert_at_2")
285 self.assert_(s1.bullets[3].text == class="st">"3")
286
287 s1.bullets.insert(999, Bullet(class="st">"999"))
288
289 self.assert_(len(s1.bullets) == 6)
290 self.assert_(s1.bullets[5].position == 5)
291
292 session = fixture_session()
293 session.add(s1)
294 session.flush()
295
296 id_ = s1.id
297 session.expunge_all()
298 del s1
299
300 srt = session.get(Slide, id_)
301
302 self.assert_(srt.bullets)
303 self.assert_(len(srt.bullets) == 6)
304
305 texts = [class="st">"1", class="st">"2", class="st">"insert_at_2", class="st">"3", class="st">"4", class="st">"999"]
306 found = [b.text for b in srt.bullets]
307
308 self.assert_(texts == found)
309
310 def test_slice(self):
311 self._setup(ordering_list(class="st">"position"))

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected