예제 #1
0
    def test_deserialize_zero_datetime(self):
        """
        Test deserialization where timestamp = 0

        Reproduces PYTHON-729

        @since 2.0.0
        @jira_ticket PYTHON-729
        @expected_result deserialization doesn't raise an error

        @test_category data_types
        """
        DateRangeType.deserialize(
            (int8_pack(1) + int64_pack(0) + int8_pack(0) + int64_pack(0) +
             int8_pack(0)), 5)
예제 #2
0
 def test_deserialize_both_open(self):
     serialized = (int8_pack(4))
     deserialized = DateRangeType.deserialize(serialized, 5)
     self.assertEqual(
         deserialized,
         util.DateRange(lower_bound=util.OPEN_BOUND,
                        upper_bound=util.OPEN_BOUND))
예제 #3
0
 def test_deserialize_single_value(self):
     serialized = (int8_pack(0) + int64_pack(self.timestamp) + int8_pack(3))
     self.assertEqual(
         DateRangeType.deserialize(serialized, 5),
         util.DateRange(value=util.DateRangeBound(value=datetime.datetime(
             2017, 2, 1, 15, 42, 12, 404000),
                                                  precision='HOUR')))
예제 #4
0
 def test_serialize_open_low(self):
     serialized = (int8_pack(2) + int64_pack(self.timestamp) + int8_pack(3))
     deserialized = DateRangeType.deserialize(serialized, 5)
     self.assertEqual(
         deserialized,
         util.DateRange(lower_bound=util.DateRangeBound(
             value=datetime.datetime(2017, 2, 1, 15), precision='HOUR'),
                        upper_bound=util.OPEN_BOUND))
예제 #5
0
 def test_serialize_single_value(self):
     serialized = (int8_pack(0) + int64_pack(self.timestamp) + int8_pack(5))
     deserialized = DateRangeType.deserialize(serialized, 5)
     self.assertEqual(
         deserialized,
         util.DateRange(value=util.DateRangeBound(value=datetime.datetime(
             2017, 2, 1, 15, 42, 12),
                                                  precision='SECOND')))
예제 #6
0
 def test_deserialize_open_low(self):
     serialized = (int8_pack(3) + int64_pack(self.timestamp) + int8_pack(4))
     deserialized = DateRangeType.deserialize(serialized, 5)
     self.assertEqual(
         deserialized,
         util.DateRange(lower_bound=util.OPEN_BOUND,
                        upper_bound=util.DateRangeBound(
                            value=datetime.datetime(2017, 2, 1, 15, 42, 20,
                                                    1000),
                            precision='MINUTE')))
예제 #7
0
 def test_deserialize_closed_range(self):
     serialized = (int8_pack(1) + int64_pack(self.timestamp) +
                   int8_pack(2) + int64_pack(self.timestamp) + int8_pack(6))
     self.assertEqual(
         DateRangeType.deserialize(serialized, 5),
         util.DateRange(lower_bound=util.DateRangeBound(
             value=datetime.datetime(2017, 2, 1, 0, 0), precision='DAY'),
                        upper_bound=util.DateRangeBound(
                            value=datetime.datetime(2017, 2, 1, 15, 42, 12,
                                                    404000),
                            precision='MILLISECOND')))
예제 #8
0
 def test_serialized_value_round_trip(self):
     vals = [
         six.
         b('\x01\x00\x00\x01%\xe9a\xf9\xd1\x06\x00\x00\x01v\xbb>o\xff\x00'),
         six.
         b('\x01\x00\x00\x00\xdcm\x03-\xd1\x06\x00\x00\x01v\xbb>o\xff\x00')
     ]
     for serialized in vals:
         self.assertEqual(
             serialized,
             DateRangeType.serialize(
                 DateRangeType.deserialize(serialized, 0), 0))
예제 #9
0
 def test_serialize_closed_range(self):
     serialized = (int8_pack(1) + int64_pack(self.timestamp) +
                   int8_pack(5) + int64_pack(self.timestamp) + int8_pack(0))
     deserialized = DateRangeType.deserialize(serialized, 5)
     self.assertEqual(
         deserialized,
         util.DateRange(lower_bound=util.DateRangeBound(
             value=datetime.datetime(2017, 2, 1, 15, 42, 12),
             precision='SECOND'),
                        upper_bound=util.DateRangeBound(
                            value=datetime.datetime(2017, 12, 31),
                            precision='YEAR')))
예제 #10
0
 def test_deserialize_single_open(self):
     self.assertEqual(util.DateRange(value=util.OPEN_BOUND),
                      DateRangeType.deserialize(int8_pack(5), 5))