예제 #1
0
def test_can_convert_to_records_without_objects_returns_false_when_records_have_arrays_in_them(
):
    store = PandasStore()
    store.to_records = Mock(
        return_value=np.rec.array([(1356998400000000000L, ['A', 'BC'])],
                                  dtype=[('index',
                                          '<M8[ns]'), ('values', 'S2',
                                                       (2, ))]))
예제 #2
0
def test_can_convert_to_records_without_objects_returns_false_when_records_have_object_dtype():
    store = PandasStore()
    store.to_records = Mock(return_value=(np.array(['a', 'b', None, 'd']), None))

    with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
        assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is False

    mock_log.info.assert_called_once_with('Pandas dataframe my_symbol contains Objects, saving as Blob')
    store.to_records.assert_called_once_with(sentinel.df)
예제 #3
0
def test_can_convert_to_records_without_objects_returns_false_on_exception_in_to_records():
    store = PandasStore()
    store.to_records = Mock(side_effect=TypeError('uhoh'))

    with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
        assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is False

    mock_log.info.assert_called_once_with('Pandas dataframe my_symbol caused exception "TypeError(\'uhoh\',)"'
                                          ' when attempting to convert to records. Saving as Blob.')
    store.to_records.assert_called_once_with(sentinel.df)
예제 #4
0
def test_can_convert_to_records_without_objects_returns_true_otherwise():
    store = PandasStore()
    store.to_records = Mock(return_value=(np.rec.array([(1356998400000000000L, 'a')],
                                                       dtype=[('index', '<M8[ns]'), ('values', 'S2')]), None))

    with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
        assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is True

    assert mock_log.info.call_count == 0
    store.to_records.assert_called_once_with(sentinel.df)
예제 #5
0
def test_can_convert_to_records_without_objects_returns_false_when_records_have_arrays_in_them():
    store = PandasStore()
    store.to_records = Mock(return_value=(np.rec.array([(1356998400000000000L, ['A', 'BC'])],
                                                       dtype=[('index', '<M8[ns]'), ('values', 'S2', (2,))]), None))

    with patch('arctic.store._pandas_ndarray_store.log') as mock_log:
        assert store.can_convert_to_records_without_objects(sentinel.df, 'my_symbol') is False

    mock_log.info.assert_called_once_with('Pandas dataframe my_symbol contains >1 dimensional arrays, saving as Blob')
    store.to_records.assert_called_once_with(sentinel.df)
예제 #6
0
def test_can_convert_to_records_without_objects_returns_true_otherwise():
    store = PandasStore()
    store.to_records = Mock(
        return_value=np.rec.array([(1356998400000000000L, 'a')],
                                  dtype=[('index', '<M8[ns]'), ('values',
                                                                'S2')]))
예제 #7
0
def test_can_convert_to_records_without_objects_returns_true_otherwise():
    store = PandasStore()
    store.to_records = Mock(return_value=np.rec.array([(1356998400000000000L, 'a')],
                                                      dtype=[('index', '<M8[ns]'), ('values', 'S2')]))
예제 #8
0
def test_can_convert_to_records_without_objects_returns_false_when_records_have_arrays_in_them():
    store = PandasStore()
    store.to_records = Mock(return_value=np.rec.array([(1356998400000000000L, ['A', 'BC'])],
                                                      dtype=[('index', '<M8[ns]'), ('values', 'S2', (2,))]))