|
8 | 8 | import warnings
|
9 | 9 | import tarantool
|
10 | 10 | import pandas
|
| 11 | +import pytz |
11 | 12 |
|
12 | 13 | from tarantool.msgpack_ext.packer import default as packer_default
|
13 | 14 | from tarantool.msgpack_ext.unpacker import ext_hook as unpacker_ext_hook
|
@@ -97,6 +98,70 @@ def setUp(self):
|
97 | 98 | 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " +
|
98 | 99 | r"nsec=308543321})",
|
99 | 100 | },
|
| 101 | + 'datetime_with_positive_offset': { |
| 102 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 103 | + microsecond=308543, nanosecond=321, |
| 104 | + tzinfo=pytz.FixedOffset(180)), |
| 105 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 106 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 107 | + r"nsec=308543321, tzoffset=180})", |
| 108 | + }, |
| 109 | + 'datetime_with_negative_offset': { |
| 110 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 111 | + microsecond=308543, nanosecond=321, |
| 112 | + tzinfo=pytz.FixedOffset(-60)), |
| 113 | + 'msgpack': (b'\x8a\xb1\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xc4\xff\x00\x00'), |
| 114 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 115 | + r"nsec=308543321, tzoffset=-60})", |
| 116 | + }, |
| 117 | + 'pandas_timestamp_with_positive_offset': { |
| 118 | + 'python': pandas.Timestamp(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 119 | + microsecond=308543, nanosecond=321, |
| 120 | + tzinfo=pytz.FixedOffset(180)), |
| 121 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 122 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 123 | + r"nsec=308543321, tzoffset=180})", |
| 124 | + }, |
| 125 | + 'pandas_timestamp_with_negative_offset': { |
| 126 | + 'python': pandas.Timestamp(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 127 | + microsecond=308543, nanosecond=321, |
| 128 | + tzinfo=pytz.FixedOffset(-60)), |
| 129 | + 'msgpack': (b'\x8a\xb1\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xc4\xff\x00\x00'), |
| 130 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 131 | + r"nsec=308543321, tzoffset=-60})", |
| 132 | + }, |
| 133 | + 'datetime_offset_replace': { |
| 134 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 135 | + microsecond=308543, nanosecond=321, |
| 136 | + ).replace(tzinfo=pytz.FixedOffset(180)), |
| 137 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 138 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 139 | + r"nsec=308543321, tzoffset=180})", |
| 140 | + }, |
| 141 | + 'datetime_offset_convert': { |
| 142 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=16, minute=7, second=54, |
| 143 | + microsecond=308543, nanosecond=321, |
| 144 | + tzinfo=pytz.FixedOffset(60)).tz_convert(pytz.FixedOffset(180)), |
| 145 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 146 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 147 | + r"nsec=308543321, tzoffset=180})", |
| 148 | + }, |
| 149 | + 'datetime_offset_localize': { |
| 150 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 151 | + microsecond=308543, nanosecond=321, |
| 152 | + ).tz_localize(pytz.FixedOffset(180)), |
| 153 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 154 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 155 | + r"nsec=308543321, tzoffset=180})", |
| 156 | + }, |
| 157 | + 'datetime_offset_astimezone': { |
| 158 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=16, minute=7, second=54, |
| 159 | + microsecond=308543, nanosecond=321, |
| 160 | + tzinfo=pytz.FixedOffset(60)).astimezone(pytz.FixedOffset(180)), |
| 161 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 162 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 163 | + r"nsec=308543321, tzoffset=180})", |
| 164 | + }, |
100 | 165 | }
|
101 | 166 |
|
102 | 167 | def test_msgpack_decode(self):
|
|
0 commit comments