Skip to content

Commit 1c742a2

Browse files
committed
fix the mocks for to_records so they now have the expected two returns. Also remove incorrect test case
1 parent 12fed9c commit 1c742a2

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

tests/unit/store/test_pandas_ndarray_store.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_can_convert_to_records_without_objects_returns_false_on_exception_in_to
2121

2222
def test_can_convert_to_records_without_objects_returns_false_when_records_have_object_dtype():
2323
store = PandasStore()
24-
store.to_records = Mock(return_value=np.array(['a', 'b', None, 'd']))
24+
store.to_records = Mock(return_value=(np.array(['a', 'b', None, 'd']), None))
2525

2626
with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
2727
assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is False
@@ -32,8 +32,8 @@ def test_can_convert_to_records_without_objects_returns_false_when_records_have_
3232

3333
def test_can_convert_to_records_without_objects_returns_false_when_records_have_arrays_in_them():
3434
store = PandasStore()
35-
store.to_records = Mock(return_value=np.rec.array([(1356998400000000000L, ['A', 'BC'])],
36-
dtype=[('index', '<M8[ns]'), ('values', 'S2', (2,))]))
35+
store.to_records = Mock(return_value=(np.rec.array([(1356998400000000000L, ['A', 'BC'])],
36+
dtype=[('index', '<M8[ns]'), ('values', 'S2', (2,))]), None))
3737

3838
with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
3939
assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is False
@@ -44,8 +44,8 @@ def test_can_convert_to_records_without_objects_returns_false_when_records_have_
4444

4545
def test_can_convert_to_records_without_objects_returns_true_otherwise():
4646
store = PandasStore()
47-
store.to_records = Mock(return_value=np.rec.array([(1356998400000000000L, 'a')],
48-
dtype=[('index', '<M8[ns]'), ('values', 'S2')]))
47+
store.to_records = Mock(return_value=(np.rec.array([(1356998400000000000L, 'a')],
48+
dtype=[('index', '<M8[ns]'), ('values', 'S2')]), None))
4949

5050
with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
5151
assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is True
@@ -54,15 +54,6 @@ def test_can_convert_to_records_without_objects_returns_true_otherwise():
5454
store.to_records.assert_called_once_with(sentinel.df)
5555

5656

57-
def test_to_records_raises_when_object_dtypes_present():
58-
store = PandasDataFrameStore()
59-
df = pd.DataFrame(data=dict(A=['a', 'b', None, 'c'], B=[1., 2., 3., 4.]), index=range(4))
60-
with raises(TypeError) as e:
61-
store.to_records(df)
62-
63-
assert "Cannot change data-type for object array." in str(e)
64-
65-
6657
def test_panel_converted_to_dataframe_and_stacked_to_write():
6758
store = PandasPanelStore()
6859
panel = Mock(shape=(1, 2, 3), axes=[Mock(names=['n%d' % i]) for i in range(3)])

0 commit comments

Comments
 (0)