Skip to content

Commit 10ba630

Browse files
committed
Unit test improvements in Chunkstore
1 parent 17ea9de commit 10ba630

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Bugfix: #169 Dtype mismatch in chunkstore updates
1111
* Feature: #171 allow deleting of values within a date range in ChunkStore
1212
* Bugfix: #172 Fix date range bug when querying dates in the middle of chunks
13+
* Bugfix: #176 Fix overwrite failures in Chunkstore
1314

1415
### 1.25 (2016-05-23)
1516

arctic/chunkstore/chunkstore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def read(self, symbol, chunk_range=None, filter_data=True):
133133

134134
sym = self._get_symbol_info(symbol)
135135
if not sym:
136-
raise NoDataFoundException('No data found for %s in library %s' % (symbol, self._collection.get_name()))
136+
raise NoDataFoundException('No data found for %s' % (symbol))
137137

138138
spec = {'symbol': symbol,
139139
}

tests/integration/chunkstore/test_chunkstore.py

+39
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import datetime as dt
33
from pandas.util.testing import assert_frame_equal, assert_series_equal
44
from arctic.date import DateRange
5+
from arctic.exceptions import NoDataFoundException
56
import pandas as pd
67
import numpy as np
78
import random
@@ -731,3 +732,41 @@ def test_read_chunk_range(chunkstore_lib):
731732

732733
df2 = chunkstore_lib.read('test', chunk_range=DateRange(None, None))
733734
assert_frame_equal(df, df2)
735+
736+
737+
def test_read_data_doesnt_exist(chunkstore_lib):
738+
with pytest.raises(NoDataFoundException) as e:
739+
chunkstore_lib.read('some_data')
740+
assert('No data found' in str(e))
741+
742+
743+
def test_invalid_type(chunkstore_lib):
744+
with pytest.raises(Exception) as e:
745+
chunkstore_lib.write('some_data', str("Cannot write a string"), 'D')
746+
assert('Can only chunk Series and DataFrames' in str(e))
747+
748+
749+
def test_append_no_data(chunkstore_lib):
750+
with pytest.raises(NoDataFoundException) as e:
751+
chunkstore_lib.append('some_data', "")
752+
assert('Symbol does not exist.' in str(e))
753+
754+
755+
def test_append_no_new_data(chunkstore_lib):
756+
df = DataFrame(data={'data': [1, 2, 3, 4, 5, 6, 7, 8, 9]},
757+
index=MultiIndex.from_tuples([(dt(2016, 1, 1), 1),
758+
(dt(2016, 1, 2), 1),
759+
(dt(2016, 1, 3), 1),
760+
(dt(2016, 2, 1), 1),
761+
(dt(2016, 2, 2), 1),
762+
(dt(2016, 2, 3), 1),
763+
(dt(2016, 3, 1), 1),
764+
(dt(2016, 3, 2), 1),
765+
(dt(2016, 3, 3), 1)],
766+
names=['date', 'id'])
767+
)
768+
769+
chunkstore_lib.write('test', df, 'D')
770+
chunkstore_lib.append('test', df)
771+
r = chunkstore_lib.read('test')
772+
assert_frame_equal(df, r)

0 commit comments

Comments
 (0)