Esempio n. 1
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')))
Esempio n. 2
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))
Esempio n. 3
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')))
Esempio n. 4
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')))
Esempio n. 5
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')))
Esempio n. 6
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')))
Esempio n. 7
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)
Esempio n. 8
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))
Esempio n. 9
0
 def test_serialize_both_open(self):
     serialized = DateRangeType.serialize(
         util.DateRange(lower_bound=util.OPEN_BOUND,
                        upper_bound=util.OPEN_BOUND), 5)
     self.assertEqual(int8_pack(4), serialized)
Esempio n. 10
0
 def test_serialize_single_open(self):
     serialized = DateRangeType.serialize(
         util.DateRange(value=util.OPEN_BOUND, ), 5)
     self.assertEqual(int8_pack(5), serialized)
Esempio n. 11
0
 def test_deserialize_single_open(self):
     self.assertEqual(util.DateRange(value=util.OPEN_BOUND),
                      DateRangeType.deserialize(int8_pack(5), 5))