def test_round_trip(self): coll = client_context.client.pymongo_test.test coll.drop() dec128 = Decimal128.from_bid( b'\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0') coll.insert_one({'dec128': dec128}) doc = coll.find_one({'dec128': dec128}) self.assertIsNotNone(doc) self.assertEqual(doc['dec128'], dec128)
def test_round_trip(self): if not client_context.version.at_least(3, 3, 6): raise unittest.SkipTest( 'Round trip test requires MongoDB >= 3.3.6') coll = client_context.client.pymongo_test.test coll.drop() dec128 = Decimal128.from_bid( b'\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0') coll.insert_one({'dec128': dec128}) doc = coll.find_one({'dec128': dec128}) self.assertIsNotNone(doc) self.assertEqual(doc['dec128'], dec128)
def test_round_trip(self): if not client_context.version.at_least(3, 3, 6): raise unittest.SkipTest( 'Round trip test requires MongoDB >= 3.3.6') coll = client_context.client.pymongo_test.test coll.drop() dec128 = Decimal128.from_bid( b'\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0') coll.insert_one({'dec128': dec128}) doc = coll.find_one({'dec128': dec128}) self.assertIsNotNone(doc) self.assertEqual(doc['dec128'], dec128)
def _get_decimal128(data, view, position, dummy0, dummy1, dummy2): """Decode a BSON decimal128 to bson.decimal128.Decimal128.""" end = position + 16 return Decimal128.from_bid(data[position:end]), end
def test_pickle(self): dec128 = Decimal128.from_bid( b'\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0') for protocol in range(pickle.HIGHEST_PROTOCOL + 1): pkl = pickle.dumps(dec128, protocol=protocol) self.assertEqual(dec128, pickle.loads(pkl))
def _get_decimal128( data: Any, view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any ) -> Tuple[Decimal128, int]: """Decode a BSON decimal128 to bson.decimal128.Decimal128.""" end = position + 16 return Decimal128.from_bid(data[position:end]), end
def _get_decimal128(data, position, dummy0, dummy1, dummy2): """Decode a BSON decimal128 to bson.decimal128.Decimal128.""" end = position + 16 return Decimal128.from_bid(data[position:end]), end
def test_pickle(self): dec128 = Decimal128.from_bid( b'\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0') for protocol in range(pickle.HIGHEST_PROTOCOL + 1): pkl = pickle.dumps(dec128, protocol=protocol) self.assertEqual(dec128, pickle.loads(pkl))