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

test: verify the error paths

parent 2427467b6a6e
......@@ -1409,3 +1409,24 @@ def test_na(engine, tsh):
def test_no_series(engine, tsh):
assert tsh.get(engine, 'inexisting_name') is None
def test_insert_errors(engine, tsh):
ts = pd.Series([1, 2, 3],
index=pd.date_range(start=utcdt(2018, 1, 1),
freq='D', periods=3))
with pytest.raises(AssertionError):
tsh.insert(engine, 42, 'error', 'Babar')
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 42, 'Babar')
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 'error', 42)
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 'error', 'Babar', _insertion_date='2010-1-1')
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 'error', 'Babar', metadata=42)
......@@ -55,7 +55,8 @@ class TimeSerie(SeriesServices):
assert isinstance(seriename, str), 'Name not a string'
assert isinstance(author, str), 'Author not a string'
assert metadata is None or isinstance(metadata, dict), 'Bad format for metadata'
assert _insertion_date is None or isinstance(_insertion_date, datetime), 'Bad format for insertion date'
assert (_insertion_date is None or
isinstance(_insertion_date, datetime)), 'Bad format for insertion date'
assert not newts.index.duplicated().any(), 'There are some duplicates in the index'
if not newts.index.is_monotonic_increasing:
......
Supports Markdown
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