|
3 | 3 | import struct
|
4 | 4 | from datetime import datetime as dt, timedelta as dtd
|
5 | 5 | import pandas as pd
|
6 |
| -from arctic import VERSION_STORE |
| 6 | +from arctic import VERSION_STORE, PandasDataFrameStore, PandasSeriesStore |
7 | 7 | from pandas.util.testing import assert_frame_equal, assert_series_equal
|
8 | 8 | from pymongo.errors import OperationFailure
|
9 | 9 | from pymongo.server_type import SERVER_TYPE
|
@@ -1587,3 +1587,23 @@ def test_write_series_with_some_objects(library, input_series):
|
1587 | 1587 | library.write(symbol='symX', data=input_series)
|
1588 | 1588 | read_data = library.read(symbol='symX').data
|
1589 | 1589 | assert_series_equal(input_series, read_data)
|
| 1590 | + |
| 1591 | + |
| 1592 | +def test_can_write_tz_aware_data_df(library): |
| 1593 | + mydf = _mixed_test_data()['index_tz_aware'][0] |
| 1594 | + library.write(symbol='symTz', data=mydf) |
| 1595 | + read_data = library.read(symbol='symTz').data |
| 1596 | + # Arctic converts by default the data to UTC, convert back |
| 1597 | + read_data.colB = read_data.colB.dt.tz_localize('UTC').dt.tz_convert(read_data.index.tzinfo) |
| 1598 | + assert library._versions.find_one({'symbol': 'symTz'})['type'] == PandasDataFrameStore.TYPE |
| 1599 | + assert_frame_equal(mydf, read_data) |
| 1600 | + |
| 1601 | + |
| 1602 | +def test_can_write_tz_aware_data_series(library): |
| 1603 | + myseries = _mixed_test_data()['index_tz_aware'][0]['colB'] |
| 1604 | + library.write(symbol='symTzSer', data=myseries) |
| 1605 | + read_data = library.read(symbol='symTzSer').data |
| 1606 | + # Arctic converts by default the data to UTC, convert back |
| 1607 | + read_data = read_data.dt.tz_localize('UTC').dt.tz_convert(read_data.index.tzinfo) |
| 1608 | + assert library._versions.find_one({'symbol': 'symTzSer'})['type'] == PandasSeriesStore.TYPE |
| 1609 | + assert_series_equal(myseries, read_data) |
0 commit comments