MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_slice

Method test_slice

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

Source from the content-addressed store, hash-verified

308 self.assert_(texts == found)
309
310 def test_slice(self):
311 self._setup(ordering_list("position"))
312
313 b = [
314 Bullet("1"),
315 Bullet("2"),
316 Bullet("3"),
317 Bullet("4"),
318 Bullet("5"),
319 Bullet("6"),
320 ]
321 s1 = Slide("Slide #1")
322
323 # 1, 2, 3
324 s1.bullets[0:3] = iter(b[0:3])
325 for i in 0, 1, 2:
326 self.assert_(s1.bullets[i].position == i)
327 self.assert_(s1.bullets[i] == b[i])
328
329 # 1, 4, 5, 6, 3
330 s1.bullets[1:2] = b[3:6]
331 for li, bi in (0, 0), (1, 3), (2, 4), (3, 5), (4, 2):
332 self.assert_(s1.bullets[li].position == li)
333 self.assert_(s1.bullets[li] == b[bi])
334
335 # 1, 6, 3
336 del s1.bullets[1:3]
337 for li, bi in (0, 0), (1, 5), (2, 2):
338 self.assert_(s1.bullets[li].position == li)
339 self.assert_(s1.bullets[li] == b[bi])
340
341 session = fixture_session()
342 session.add(s1)
343 session.flush()
344
345 id_ = s1.id
346 session.expunge_all()
347 del s1
348
349 srt = session.get(Slide, id_)
350
351 self.assert_(srt.bullets)
352 self.assert_(len(srt.bullets) == 3)
353
354 texts = ["1", "6", "3"]
355 for i, text in enumerate(texts):
356 self.assert_(srt.bullets[i].position == i)
357 self.assert_(srt.bullets[i].text == text)
358
359 def test_replace(self):
360 self._setup(ordering_list("position"))

Callers

nothing calls this directly

Calls 10

_setupMethod · 0.95
ordering_listFunction · 0.90
fixture_sessionFunction · 0.90
BulletClass · 0.70
SlideClass · 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