|
10 | 10 | import warnings
|
11 | 11 | import tarantool
|
12 | 12 | import pandas
|
| 13 | +import pytz |
13 | 14 |
|
14 | 15 | from tarantool.msgpack_ext.packer import default as packer_default
|
15 | 16 | from tarantool.msgpack_ext.unpacker import ext_hook as unpacker_ext_hook
|
@@ -559,6 +560,62 @@ def test_UUID_tarantool_encode(self):
|
559 | 560 | 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " +
|
560 | 561 | r"nsec=308543321})",
|
561 | 562 | },
|
| 563 | + 'datetime_with_positive_offset': { |
| 564 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 565 | + microsecond=308543, nanosecond=321, |
| 566 | + tzinfo=pytz.FixedOffset(180)), |
| 567 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 568 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 569 | + r"nsec=308543321, tzoffset=180})", |
| 570 | + }, |
| 571 | + 'datetime_with_negative_offset': { |
| 572 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 573 | + microsecond=308543, nanosecond=321, |
| 574 | + tzinfo=pytz.FixedOffset(-60)), |
| 575 | + 'msgpack': (b'\x8a\xb1\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xc4\xff\x00\x00'), |
| 576 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 577 | + r"nsec=308543321, tzoffset=-60})", |
| 578 | + }, |
| 579 | + 'pandas_timestamp_with_positive_offset': { |
| 580 | + 'python': pandas.Timestamp(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 581 | + microsecond=308543, nanosecond=321, |
| 582 | + tzinfo=pytz.FixedOffset(180)), |
| 583 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 584 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 585 | + r"nsec=308543321, tzoffset=180})", |
| 586 | + }, |
| 587 | + 'pandas_timestamp_with_negative_offset': { |
| 588 | + 'python': pandas.Timestamp(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 589 | + microsecond=308543, nanosecond=321, |
| 590 | + tzinfo=pytz.FixedOffset(-60)), |
| 591 | + 'msgpack': (b'\x8a\xb1\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xc4\xff\x00\x00'), |
| 592 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 593 | + r"nsec=308543321, tzoffset=-60})", |
| 594 | + }, |
| 595 | + 'datetime_offset_replace': { |
| 596 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=18, minute=7, second=54, |
| 597 | + microsecond=308543, nanosecond=321, |
| 598 | + ).replace(tzinfo=pytz.FixedOffset(180)), |
| 599 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 600 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 601 | + r"nsec=308543321, tzoffset=180})", |
| 602 | + }, |
| 603 | + 'datetime_offset_convert': { |
| 604 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=16, minute=7, second=54, |
| 605 | + microsecond=308543, nanosecond=321, |
| 606 | + tzinfo=pytz.FixedOffset(60)).tz_convert(pytz.FixedOffset(180)), |
| 607 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 608 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 609 | + r"nsec=308543321, tzoffset=180})", |
| 610 | + }, |
| 611 | + 'datetime_offset_astimezone': { |
| 612 | + 'python': tarantool.Datetime(year=2022, month=8, day=31, hour=16, minute=7, second=54, |
| 613 | + microsecond=308543, nanosecond=321, |
| 614 | + tzinfo=pytz.FixedOffset(60)).astimezone(pytz.FixedOffset(180)), |
| 615 | + 'msgpack': (b'\x4a\x79\x0f\x63\x00\x00\x00\x00\x59\xff\x63\x12\xb4\x00\x00\x00'), |
| 616 | + 'tarantool': r"datetime.new({year=2022, month=8, day=31, hour=18, min=7, sec=54, " + |
| 617 | + r"nsec=308543321, tzoffset=180})", |
| 618 | + }, |
562 | 619 | }
|
563 | 620 |
|
564 | 621 | def test_datetime_msgpack_decode(self):
|
|
0 commit comments