MCPcopy
hub / github.com/quantopian/zipline / test_clean_keep_last

Method test_clean_keep_last

tests/data/bundles/test_core.py:402–470  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

400 return _wrote_to[0]
401
402 def test_clean_keep_last(self):
403 first = self._empty_ingest()
404
405 assert_equal(
406 self.clean('bundle', keep_last=1, environ=self.environ),
407 set(),
408 )
409 assert_equal(
410 self._list_bundle(),
411 {first},
412 msg='directory should not have changed',
413 )
414
415 second = self._empty_ingest()
416 assert_equal(
417 self._list_bundle(),
418 {first, second},
419 msg='two ingestions are not present',
420 )
421 assert_equal(
422 self.clean('bundle', keep_last=1, environ=self.environ),
423 {first},
424 )
425 assert_equal(
426 self._list_bundle(),
427 {second},
428 msg='first ingestion was not removed with keep_last=2',
429 )
430
431 third = self._empty_ingest()
432 fourth = self._empty_ingest()
433 fifth = self._empty_ingest()
434
435 assert_equal(
436 self._list_bundle(),
437 {second, third, fourth, fifth},
438 msg='larger set of ingestions did not happen correctly',
439 )
440
441 assert_equal(
442 self.clean('bundle', keep_last=2, environ=self.environ),
443 {second, third},
444 )
445
446 assert_equal(
447 self._list_bundle(),
448 {fourth, fifth},
449 msg='keep_last=2 did not remove the correct number of ingestions',
450 )
451
452 with assert_raises(BadClean):
453 self.clean('bundle', keep_last=-1, environ=self.environ)
454
455 assert_equal(
456 self._list_bundle(),
457 {fourth, fifth},
458 msg='keep_last=-1 removed some ingestions',
459 )

Callers

nothing calls this directly

Calls 3

_empty_ingestMethod · 0.95
_list_bundleMethod · 0.95
assert_equalFunction · 0.90

Tested by

no test coverage detected