BUG: Fixes should_clean for keep_last=0

This commit is contained in:
Richard Frank
2016-08-17 18:18:01 -04:00
parent 08a03edad7
commit cbcb71bbad
2 changed files with 26 additions and 4 deletions
+21 -1
View File
@@ -7,7 +7,7 @@ import toolz.curried.operator as op
from zipline.assets.synthetic import make_simple_equity_info
from zipline.data.bundles import UnknownBundle, from_bundle_ingest_dirname
from zipline.data.bundles.core import _make_bundle_core
from zipline.data.bundles.core import _make_bundle_core, BadClean
from zipline.lib.adjustment import Float64Multiply
from zipline.pipeline.loaders.synthetic import (
make_bar_data,
@@ -369,6 +369,26 @@ class BundleCoreTestCase(WithInstanceTmpDir, ZiplineTestCase):
msg='keep_last=2 did not remove the correct number of ingestions',
)
with assert_raises(BadClean):
self.clean('bundle', keep_last=-1, environ=self.environ)
assert_equal(
self._list_bundle(),
{fourth, fifth},
msg='keep_last=-1 removed some ingestions',
)
assert_equal(
self.clean('bundle', keep_last=0, environ=self.environ),
{fourth, fifth},
)
assert_equal(
self._list_bundle(),
set(),
msg='keep_last=0 did not remove the correct number of ingestions',
)
@staticmethod
def _ts_of_run(run):
return from_bundle_ingest_dirname(run.rsplit(os.path.sep, 1)[-1])