|
1 | 1 | from datetime import datetime as dt
|
2 |
| -from mock import create_autospec |
| 2 | + |
| 3 | +from mock import create_autospec, sentinel |
3 | 4 | from pandas.util.testing import assert_frame_equal
|
| 5 | +import pytest |
4 | 6 |
|
5 | 7 | from arctic.store.bitemporal_store import BitemporalStore
|
6 | 8 | from tests.util import read_str_as_pandas
|
|
12 | 14 | 2012-10-09 17:06:11.040 | 2.5
|
13 | 15 | 2012-11-08 17:06:11.040 | 3.0""")
|
14 | 16 |
|
| 17 | + |
15 | 18 | def test_add_observe_dt_index():
|
16 |
| - self = create_autospec(BitemporalStore, observe_column='col_a', |
17 |
| - sample_column='col_b') |
| 19 | + self = create_autospec(BitemporalStore, observe_column='col_a') |
18 | 20 | assert_frame_equal(BitemporalStore._add_observe_dt_index(self, ts1, as_of=dt(2001, 1, 1)),
|
19 |
| - read_str_as_pandas("""col_b | col_a | near |
20 |
| - 2012-09-08 17:06:11.040 | 2001-01-01 | 1.0 |
21 |
| - 2012-10-08 17:06:11.040 | 2001-01-01 | 2.0 |
22 |
| - 2012-10-09 17:06:11.040 | 2001-01-01 | 2.5 |
23 |
| - 2012-11-08 17:06:11.040 | 2001-01-01 | 3.0""", num_index=2)) |
| 21 | + read_str_as_pandas("""sample_dt | col_a | near |
| 22 | + 2012-09-08 17:06:11.040 | 2001-01-01 | 1.0 |
| 23 | + 2012-10-08 17:06:11.040 | 2001-01-01 | 2.0 |
| 24 | + 2012-10-09 17:06:11.040 | 2001-01-01 | 2.5 |
| 25 | + 2012-11-08 17:06:11.040 | 2001-01-01 | 3.0""", num_index=2)) |
| 26 | + |
| 27 | + |
| 28 | +def test_update_with_observe_column_fails(): |
| 29 | + self = create_autospec(BitemporalStore, observe_column='col_a') |
| 30 | + with pytest.raises(ValueError) as e: |
| 31 | + BitemporalStore.update(self, sentinel.symbol, read_str_as_pandas( |
| 32 | + """col_b | col_a | near |
| 33 | + 2012-09-08 17:06:11.040 | 2001-01-01 | 1.0""", num_index=2)) |
| 34 | + assert str(e.value) == "Column col_a is not allowed as it is being used by bitemporal store interally." |
0 commit comments