Commit f6b8ea2d authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

strip: add a safety belt for supervised series

And indeed we do not want to strip those.
parent 2cb2f0b4b9e9
......@@ -277,6 +277,42 @@ def test_manual_overrides(engine, tsh):
""", manual)
def test_strip(engine, tsh):
ts = genserie(datetime(2019, 1, 1), 'D', 3)
tsh.insert(
engine, ts, 'strip-unsupervised', 'test',
_insertion_date=utcdt(2019, 1, 1)
)
csid = tsh.changeset_at(engine, 'strip-unsupervised', utcdt(2019, 1, 1))
tsh.strip(engine, 'strip-unsupervised', csid)
ts = genserie(datetime(2019, 1, 1), 'D', 3)
tsh.insert(
engine, ts, 'strip-handcrafted', 'test',
manual=True,
_insertion_date=utcdt(2019, 1, 1)
)
csid = tsh.changeset_at(engine, 'strip-handcrafted', utcdt(2019, 1, 1))
tsh.strip(engine, 'strip-handcrafted', csid)
ts = genserie(datetime(2019, 1, 1), 'D', 3)
tsh.insert(
engine, ts, 'strip-supervised', 'test',
_insertion_date=utcdt(2019, 1, 1)
)
ts = genserie(datetime(2019, 1, 2), 'D', 3)
tsh.insert(
engine, ts, 'strip-supervised', 'test',
manual=True,
_insertion_date=utcdt(2019, 1, 2)
)
with pytest.raises(ValueError) as err:
csid = tsh.changeset_at(engine, 'strip-supervised', utcdt(2019, 1, 1))
tsh.strip(engine, 'strip-supervised', csid)
def test_handcrafted(engine, tsh):
ts_begin = genserie(datetime(2010, 1, 1), 'D', 10)
tsh.insert(engine, ts_begin, 'ts_only', 'test', manual=True)
......
......@@ -152,6 +152,13 @@ class timeseries(basets):
super().rename(cn, oldname, newname)
self.upstream.rename(cn, oldname, newname)
@tx
def strip(self, cn, name, csid):
if self.supervision_status(cn, name) == 'supervised':
raise ValueError(f'supervised series `{name}` cannot be striped')
super().strip(cn, name, csid)
# supervision specific API
@tx
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment