def generate_scalars_binary(scalars_map, preceding_symbols=0): for ion_type, values in six.iteritems(scalars_map): for native, expected in values: native_expected = expected has_symbols = False if native is None: # An un-adorned 'None' doesn't contain enough information to determine its Ion type native_expected = b'\x0f' elif ion_type is IonType.CLOB: # All six.binary_type are treated as BLOBs unless wrapped by an _IonNature tid = six.byte2int( expected ) + 0x10 # increment upper nibble for clob -> blob; keep lower nibble native_expected = bytearray([tid]) + expected[1:] elif ion_type is IonType.SYMBOL and native is not None: has_symbols = True elif ion_type is IonType.STRING: # Encode all strings as symbols too. symbol_expected = _serialize_symbol( IonEvent(IonEventType.SCALAR, IonType.SYMBOL, SymbolToken(None, 10 + preceding_symbols))) yield _Parameter(IonType.SYMBOL.name + ' ' + native, IonPyText.from_value(IonType.SYMBOL, native), symbol_expected, True) yield _Parameter('%s %s' % (ion_type.name, native), native, native_expected, has_symbols) wrapper = _FROM_ION_TYPE[ion_type].from_value(ion_type, native) yield _Parameter(repr(wrapper), wrapper, expected, has_symbols)
def test_symbol(): if is_pypy: return ion_value = loads(dumps(SymbolToken(six.text_type("Symbol"), None))) assert isinstance(ion_value, IonPySymbol) and ion_value.ion_type == IonType.SYMBOL json_string = json.dumps(ion_value, cls=IonToJSONEncoder) assert json_string == '"Symbol"'
def _generate_annotated_values(): for value_p in chain(_generate_simple_scalars(), _generate_simple_containers()): events = (value_p.events[0].derive_annotations( [SymbolToken(None, 10), SymbolToken(None, 11)]),) + value_p.events[1:] annot_length = 2 # 10 and 11 each fit in one VarUInt byte annot_length_length = 1 # 2 fits in one VarUInt byte value_length = len(value_p.expected) length_field = annot_length + annot_length_length + value_length wrapper = [] _write_length(wrapper, length_field, 0xE0) wrapper.extend([ VARUINT_END_BYTE | annot_length, VARUINT_END_BYTE | 10, VARUINT_END_BYTE | 11 ]) yield _P( desc='ANN %s' % value_p.desc, events=events + (_E(_ET.STREAM_END),), expected=bytearray(wrapper) + value_p.expected, )
def compare_digests(value, hash_files, digest_comparisons): """ For the given test value, reads the hash computed by each impl and determines whether the implementations are consistent or inconsistent. :param value: the Ion value to compare hashes of :param hash_files: dict of implementation name to an open file object of hashes produced by that implementation. :param digest_comparisons: a dict summarizing the result for `value` :return: 'consistent', 'inconsistent', or 'no_comparison' """ digests = {} for impl_name, hash_file in hash_files.items(): digest = hash_file.readline().rstrip() if digest.startswith("[unable to digest"): digests[impl_name] = "[unable to digest]" else: digests[impl_name] = digest digest_set = set(digests.values()) digest_comparison = {} if len(digest_set) == 0: result = 'no_comparison' elif len(digest_set) == 1: result = 'consistent' digest_comparison['digest'] = digest_set.pop() else: result = 'inconsistent' impl_digests = {} for impl_name, digest in digests.items(): impl_digests[impl_name] = digest digest_comparison['digests'] = impl_digests digest_comparison['result'] = SymbolToken(result, None, None) digest_comparison['value'] = simpleion.dumps(value, binary=False, omit_version_marker=True) digest_comparisons.append(digest_comparison) return result
def test_no_fieldname_in_hash(test_data): """ This test verifies a hash_reader/writer that receives field events but did not receive the preceeding "begin struct" event DOES NOT include the field_name as part of the hash. """ reader = binary_reader_over(test_data.ion_str) events = consume(reader) buf = BytesIO() writer = blocking_writer(raw_writer(), buf) writer.send(IonEvent(IonEventType.CONTAINER_START, IonType.STRUCT)) hw = hash_writer(writer, hash_function_provider("identity")) for e in events[:-1]: field_name = e.field_name if e.depth == 0: field_name = SymbolToken("field_name", None) new_event = IonEvent(e.event_type, e.ion_type, e.value, field_name, e.annotations, e.depth + 1) hw.send(new_event) writer.send(IonEvent(IonEventType.CONTAINER_END, IonType.STRUCT)) writer.send(events[-1]) # send the final event (which should be a STREAM_END event) output = buf.getvalue() hw_digest = hw.send(HashEvent.DIGEST) assert hw_digest == test_data.expected_digest reader = binary_reader_over(output) hr_digest = b'' while True: event = reader.send(NEXT_EVENT) if event.event_type == IonEventType.CONTAINER_START: hr = hash_reader(reader, hash_function_provider("identity")) for i in range(0, len(events) - 1): e = hr.send(NEXT_EVENT) hr_digest = hr.send(HashEvent.DIGEST) if event.event_type == IonEventType.STREAM_END: break assert hr_digest == test_data.expected_digest
def to_event(self, event_type, field_name=None, in_struct=False, depth=None): """Constructs an IonEvent from this _IonNature value. Args: event_type (IonEventType): The type of the resulting event. field_name (Optional[text]): The field name associated with this value, if any. When ``None`` is specified and ``in_struct`` is ``True``, the returned event's ``field_name`` will represent symbol zero (a ``SymbolToken`` with text=None and sid=0). in_struct (Optional[True|False]): When ``True``, indicates the returned event ``field_name`` will be populated. When ``False``, ``field_name`` will be ``None``. depth (Optional[int]): The depth of this value. Returns: An IonEvent with the properties from this value. """ value = self if isinstance(self, IonPyNull) or self.ion_type.is_container: value = None if in_struct: if not isinstance(field_name, SymbolToken): field_name = SymbolToken(field_name, 0 if field_name is None else None) else: field_name = None return IonEvent(event_type, ion_type=self.ion_type, value=value, field_name=field_name, annotations=self.ion_annotations, depth=depth)
), ( (_E(_ET.SCALAR, _IT.INT, 0),), bytearray([ 0xC0 | 0x01, # Int value 0 fits in 1 byte. ION_ENCODED_INT_ZERO ]) ), ), _IT.STRUCT: ( ( (), b'\xD0' ), ( (_E(_ET.SCALAR, _IT.INT, 0, field_name=SymbolToken(None, 10)),), bytearray([ 0xDE, # The lower nibble may vary by implementation. It does not indicate actual length unless it's 0. VARUINT_END_BYTE | 2, # Field name 10 and value 0 each fit in 1 byte. VARUINT_END_BYTE | 10, ION_ENCODED_INT_ZERO ]) ), ), } _generate_simple_scalars = partial(generate_scalars, SIMPLE_SCALARS_MAP_BINARY, True) _generate_simple_containers = partial(generate_containers, _SIMPLE_CONTAINER_MAP, True)
), _IT.TIMESTAMP: ( (None, b'null.timestamp'), (_DT(2016, 1, 1), b'2016-01-01T00:00:00.000000-00:00'), (_DT(2016, 1, 1, 12), b'2016-01-01T12:00:00.000000-00:00'), (_DT(2016, 1, 1, 12, 34, 12), b'2016-01-01T12:34:12.000000-00:00'), (_DT(2016, 1, 1, 12, 34, 12, 555000), b'2016-01-01T12:34:12.555000-00:00'), (_DT(2016, 1, 1, 12, 34, 12, tzinfo=OffsetTZInfo()), b'2016-01-01T12:34:12.000000Z'), (_DT(2016, 1, 1, 12, 34, 12, tzinfo=OffsetTZInfo(timedelta(hours=-7))), b'2016-01-01T12:34:12.000000-07:00'), ), _IT.SYMBOL: ( (None, b'null.symbol'), (SymbolToken(None, 4), b'$4'), # System symbol 'name'. (SymbolToken(u'a token', 400), b"'a token'"), ) + _SIMPLE_SYMBOLS_TEXT, _IT.STRING: ((None, b'null.string'), ) + _SIMPLE_STRINGS_TEXT, _IT.CLOB: ((None, b'null.clob'), ) + _SIMPLE_CLOBS_TEXT, _IT.BLOB: ((None, b'null.blob'), ) + _SIMPLE_BLOBS_TEXT, _IT.LIST: ((None, b'null.list'), ), _IT.SEXP: ((None, b'null.sexp'), ), _IT.STRUCT: ((None, b'null.struct'), ), } SIMPLE_SCALARS_MAP_BINARY = { _IT.NULL: ((None, b'\x0F'), ), _IT.BOOL: ((None, b'\x1F'), (False, b'\x10'), (True, b'\x11')), _IT.INT: ( (None, b'\x2F'),
def as_symbol(self): return SymbolToken(self.__text, sid=None, location=None)
def _containerize_params(params, with_skip=True): """Adds container wrappers for a given iteration of parameters. The requirement is that each parameter is a self-contained single value. """ rnd = Random() rnd.seed(0xC0FFEE) params = list(params) for param in params: data_len = _data_event_len(param.event_pairs) for tid in _CONTAINER_TIDS: ion_type = _TID_VALUE_TYPE_TABLE[tid] field_data = b'' field_tok = None field_desc = '' if ion_type is IonType.STRUCT: field_sid = rnd.randint(0, 0x7F) field_data = int2byte(field_sid | 0x80) field_tok = SymbolToken(None, field_sid) field_desc = ' (f:0x%02X)' % field_sid @listify def add_field_names(event_pairs): first = True for read_event, ion_event in event_pairs: if first and not ion_event.event_type.is_stream_signal: ion_event = ion_event.derive_field_name(field_tok) first = False yield read_event, ion_event type_header = _gen_type_len( tid, data_len + len(field_data)) + field_data start = [(NEXT, END), (e_read(type_header), e_start(ion_type)), (NEXT, INC)] mid = add_field_names(param.event_pairs[1:-1]) end = [(NEXT, e_end(ion_type)), (NEXT, END)] desc = 'SINGLETON %s%s - %s' % (ion_type.name, field_desc, param.desc) yield _P( desc=desc, event_pairs=start + mid + end, ) # Version with SKIP if with_skip: @listify def only_data_inc(event_pairs): for read_event, ion_event in event_pairs: if read_event.type is ReadEventType.DATA: yield read_event, INC start = start[:-1] + [(SKIP, INC)] end = only_data_inc(param.event_pairs) end = end[:-1] + [(end[-1][0], e_end(ion_type)), (NEXT, END)] yield _P( desc='SKIP %s' % desc, event_pairs=start + end, )
b'\x6C\x43\xA4\x0F\xE0\x82\x82\x87\x80\x9E\xC6\x03\xE8', # The last three octets represent 1000d-6 e_timestamp( _ts(2016, 2, 2, 0, 0, 30, 1000, off_hours=-7, precision=TimestampPrecision.SECOND, fractional_precision=6)), ), (b'\x7F', e_symbol()), (b'\x70', e_symbol(SYMBOL_ZERO_TOKEN)), (b'\x71\x02', e_symbol(SymbolToken(None, 2))), (b'\x7A' + b'\xFF' * 10, e_symbol(SymbolToken(None, 0xFFFFFFFFFFFFFFFFFFFF))), (b'\x8F', e_string()), (b'\x80', e_string(u'')), (b'\x84\xf0\x9f\x92\xa9', e_string(u'\U0001F4A9')), (b'\x88$ion_1_0', e_string(u'$ion_1_0')), (b'\x9F', e_clob()), (b'\x90', e_clob(b'')), (b'\x94\xf0\x9f\x92\xa9', e_clob(b'\xf0\x9f\x92\xa9')), (b'\xAF', e_blob()), (b'\xA0', e_blob(b'')), (b'\xA4\xf0\x9f\x92\xa9', e_blob(b'\xf0\x9f\x92\xa9')), (b'\xBF', e_null_list()), (b'\xB0', e_start_list(), e_end_list()), (b'\xCF', e_null_sexp()),
), ), _IT.SEXP: (( (), b'()', ), ), _IT.STRUCT: (( (), b'{}', ), ), } _generate_simple_scalars = partial(generate_scalars, SIMPLE_SCALARS_MAP_TEXT) _generate_empty_containers = partial(generate_containers, _EMPTY_CONTAINER_MAP) _SIMPLE_ANNOTATIONS = ( SymbolToken(None, 4), # System symbol 'name'. u'\x00', u'\uff4e', # An full-width latin 'n' code point. u'\U0001f4a9', # A 'pile of poo' emoji code point. ) _SIMPLE_ANNOTATIONS_ENCODED = br"$4::'\x00'::'\uff4e'::'\U0001f4a9'::" def _generate_annotated_values(): for value_p in chain(_generate_simple_scalars(), _generate_empty_containers()): events = (value_p.events[0].derive_annotations(_SIMPLE_ANNOTATIONS), ) + value_p.events[1:] yield _P( desc='ANN %s' % value_p.desc, events=events,
_equivs_timestamp_instants_param = partial(_equivs_param, timestamp_instants_only=True) def _nonequivs_param(a, b): def assert_not_equivalent(): assert not ion_equals(a, b) assert not ion_equals(b, a) return _P(_desc(a, b, '!='), assert_not_equivalent) _TEST_ANNOTATIONS = ( (u'abc',), (u'abc', u'def'), (SymbolToken(text=None, sid=10), SymbolToken(text=None, sid=11)), ) def _generate_annotations(): """Circularly generates sequences of test annotations. The annotations sequence yielded from this generator must never be equivalent to the annotations sequence last yielded by this generator. """ i = 0 while True: yield _TEST_ANNOTATIONS[i] i += 1 if i == len(_TEST_ANNOTATIONS): i = 0 _annotations_generator = iter(_generate_annotations())
), _IT.TIMESTAMP: ( (None, b'null.timestamp'), (_DT(2016, 1, 1), b'2016-01-01T00:00:00-00:00'), (_DT(2016, 1, 1, 12), b'2016-01-01T12:00:00-00:00'), (_DT(2016, 1, 1, 12, 34, 12), b'2016-01-01T12:34:12-00:00'), (_DT(2016, 1, 1, 12, 34, 12, 555000), b'2016-01-01T12:34:12.555000-00:00'), (_DT(2016, 1, 1, 12, 34, 12, tzinfo=OffsetTZInfo()), b'2016-01-01T12:34:12+00:00'), (_DT(2016, 1, 1, 12, 34, 12, tzinfo=OffsetTZInfo(timedelta(hours=-7))), b'2016-01-01T12:34:12-07:00'), ), _IT.SYMBOL: ( (None, b'null.symbol'), (SymbolToken(None, 4), b'$4'), # System symbol 'name'. (SymbolToken(u'a token', 400), b"'a token'"), ) + _SIMPLE_SYMBOLS, _IT.STRING: ((None, b'null.string'), ) + _SIMPLE_STRINGS, _IT.CLOB: ((None, b'null.clob'), ) + _SIMPLE_CLOBS, _IT.BLOB: ((None, b'null.blob'), ) + _SIMPLE_BLOBS, _IT.LIST: ((None, b'null.list'), ), _IT.SEXP: ((None, b'null.sexp'), ), _IT.STRUCT: ((None, b'null.struct'), ), } _EMPTY_CONTAINER_MAP = { _IT.LIST: (( (), b'[]', ), ),
""" try: with create_qldb_session() as session: ion_clob = convert_object_to_ion( loads('{{"This is a CLOB of text."}}')) ion_blob = convert_object_to_ion(str.encode('hello')) ion_bool = convert_object_to_ion(True) ion_decimal = convert_object_to_ion(Decimal('0.1')) ion_float = convert_object_to_ion(float('0.2')) ion_int = convert_object_to_ion(1) ion_list = convert_object_to_ion([1, 2]) ion_null = convert_object_to_ion(None) ion_sexp = convert_object_to_ion(loads('(cons 1 2)')) ion_string = convert_object_to_ion("string") ion_struct = convert_object_to_ion({"brand": "Ford"}) ion_symbol = convert_object_to_ion(SymbolToken(text='abc', sid=123)) ion_timestamp = convert_object_to_ion( datetime(2016, 12, 20, 5, 23, 43)) ion_null_clob = convert_object_to_ion(loads('null.clob')) ion_null_blob = convert_object_to_ion(loads('null.blob')) ion_null_bool = convert_object_to_ion(loads('null.bool')) ion_null_decimal = convert_object_to_ion(loads('null.decimal')) ion_null_float = convert_object_to_ion(loads('null.float')) ion_null_int = convert_object_to_ion(loads('null.int')) ion_null_list = convert_object_to_ion(loads('null.list')) ion_null_sexp = convert_object_to_ion(loads('null.sexp')) ion_null_string = convert_object_to_ion(loads('null.string')) ion_null_struct = convert_object_to_ion(loads('null.struct')) ion_null_symbol = convert_object_to_ion(loads('null.symbol')) ion_null_timestamp = convert_object_to_ion(loads('null.timestamp'))
from datetime import datetime from decimal import Decimal from tests import parametrize, listify from tests.event_aliases import * from amazon.ion.core import Timestamp, TimestampPrecision from amazon.ion.util import record from amazon.ion.symbols import SymbolToken from amazon.ion.simple_types import is_null, IonPyNull, IonPyBool, IonPyInt, IonPyFloat, \ IonPyDecimal, IonPyTimestamp, IonPyText, IonPyBytes, \ IonPyList, IonPyDict, IonPySymbol from amazon.ion.equivalence import ion_equals from amazon.ion.simpleion import _ion_type, _FROM_TYPE _TEST_FIELD_NAME = SymbolToken('foo', 10) _TEST_ANNOTATIONS = (SymbolToken('bar', 11), ) class _P(record('desc', 'type', 'event')): def __str__(self): return self.desc _EVENT_TYPES = [ (IonPyNull, e_null()), (IonPyNull, e_int(None)), (IonPyBool, e_bool(True)), (IonPyInt, e_int(65000)), (IonPyInt, e_int(2**64 + 1)), (IonPyFloat, e_float(1e0)),
def _to_event_parameters(): return [ [ loads('5'), [IonEvent(IonEventType.SCALAR, IonType.INT, 5, None, (), depth=0)] ], [ loads('abc'), [ IonEvent(IonEventType.SCALAR, IonType.SYMBOL, SymbolToken('abc', None), None, (), depth=0) ] ], [ loads('{abc: 1}'), [ IonEvent(IonEventType.CONTAINER_START, IonType.STRUCT, depth=0), IonEvent(IonEventType.SCALAR, IonType.INT, 1, SymbolToken('abc', None), (), depth=1), IonEvent(IonEventType.CONTAINER_END), ] ], [ loads('$0'), [ IonEvent(IonEventType.SCALAR, IonType.SYMBOL, SymbolToken(None, 0), None, (), depth=0) ] ], [ loads('{$0: $0}'), [ IonEvent(IonEventType.CONTAINER_START, IonType.STRUCT, depth=0), IonEvent(IonEventType.SCALAR, IonType.SYMBOL, IonPySymbol(None, 0), SymbolToken(None, 0), (), depth=1), IonEvent(IonEventType.CONTAINER_END), ] ], [ loads('[1, 2, 3, [4, 5, 6], [7, 8, 9]]'), [ IonEvent(IonEventType.CONTAINER_START, IonType.LIST, depth=0), IonEvent(IonEventType.SCALAR, IonType.INT, 1, depth=1), IonEvent(IonEventType.SCALAR, IonType.INT, 2, depth=1), IonEvent(IonEventType.SCALAR, IonType.INT, 3, depth=1), IonEvent(IonEventType.CONTAINER_START, IonType.LIST, depth=1), IonEvent(IonEventType.SCALAR, IonType.INT, 4, depth=2), IonEvent(IonEventType.SCALAR, IonType.INT, 5, depth=2), IonEvent(IonEventType.SCALAR, IonType.INT, 6, depth=2), IonEvent(IonEventType.CONTAINER_END), IonEvent(IonEventType.CONTAINER_START, IonType.LIST, depth=1), IonEvent(IonEventType.SCALAR, IonType.INT, 7, depth=2), IonEvent(IonEventType.SCALAR, IonType.INT, 8, depth=2), IonEvent(IonEventType.SCALAR, IonType.INT, 9, depth=2), IonEvent(IonEventType.CONTAINER_END), IonEvent(IonEventType.CONTAINER_END), ] ], [ 5, [IonEvent(IonEventType.SCALAR, IonType.INT, 5, None, (), depth=0)] ], [ u'abc', [ IonEvent(IonEventType.SCALAR, IonType.STRING, "abc", None, (), depth=0) ] ], [{ 'abc': 1 }, [ IonEvent(IonEventType.CONTAINER_START, IonType.STRUCT, depth=0), IonEvent(IonEventType.SCALAR, IonType.INT, 1, "abc", (), depth=1), IonEvent(IonEventType.CONTAINER_END), ]], ]
def insert_and_verify_ion_types(driver): """ Insert all the supported Ion types and Python values that are convertible to Ion into a ledger and verify that they are stored and can be retrieved properly, retaining their original properties. :type driver: :py:class:`pyqldb.driver.qldb_driver.QldbDriver` :param driver: A QLDB Driver object. """ python_bytes = str.encode('hello') python_bool = True python_float = float('0.2') python_decimal = Decimal('0.1') python_string = "string" python_int = 1 python_null = None python_datetime = datetime(2016, 12, 20, 5, 23, 43) python_list = [1, 2] python_dict = {"brand": "Ford"} ion_clob = convert_object_to_ion(loads('{{"This is a CLOB of text."}}')) ion_blob = convert_object_to_ion(python_bytes) ion_bool = convert_object_to_ion(python_bool) ion_decimal = convert_object_to_ion(python_decimal) ion_float = convert_object_to_ion(python_float) ion_int = convert_object_to_ion(python_int) ion_list = convert_object_to_ion(python_list) ion_null = convert_object_to_ion(python_null) ion_sexp = convert_object_to_ion(loads('(cons 1 2)')) ion_string = convert_object_to_ion(python_string) ion_struct = convert_object_to_ion(python_dict) ion_symbol = convert_object_to_ion(SymbolToken(text='abc', sid=123)) ion_timestamp = convert_object_to_ion(python_datetime) ion_null_clob = convert_object_to_ion(loads('null.clob')) ion_null_blob = convert_object_to_ion(loads('null.blob')) ion_null_bool = convert_object_to_ion(loads('null.bool')) ion_null_decimal = convert_object_to_ion(loads('null.decimal')) ion_null_float = convert_object_to_ion(loads('null.float')) ion_null_int = convert_object_to_ion(loads('null.int')) ion_null_list = convert_object_to_ion(loads('null.list')) ion_null_sexp = convert_object_to_ion(loads('null.sexp')) ion_null_string = convert_object_to_ion(loads('null.string')) ion_null_struct = convert_object_to_ion(loads('null.struct')) ion_null_symbol = convert_object_to_ion(loads('null.symbol')) ion_null_timestamp = convert_object_to_ion(loads('null.timestamp')) create_table(driver, TABLE_NAME) insert_documents(driver, TABLE_NAME, [{'Name': 'val'}]) update_record_and_verify_type(driver, python_bytes, IonPyBytes, IonType.BLOB) update_record_and_verify_type(driver, python_bool, IonPyBool, IonType.BOOL) update_record_and_verify_type(driver, python_float, IonPyFloat, IonType.FLOAT) update_record_and_verify_type(driver, python_decimal, IonPyDecimal, IonType.DECIMAL) update_record_and_verify_type(driver, python_string, IonPyText, IonType.STRING) update_record_and_verify_type(driver, python_int, IonPyInt, IonType.INT) update_record_and_verify_type(driver, python_null, IonPyNull, IonType.NULL) update_record_and_verify_type(driver, python_datetime, IonPyTimestamp, IonType.TIMESTAMP) update_record_and_verify_type(driver, python_list, IonPyList, IonType.LIST) update_record_and_verify_type(driver, python_dict, IonPyDict, IonType.STRUCT) update_record_and_verify_type(driver, ion_clob, IonPyBytes, IonType.CLOB) update_record_and_verify_type(driver, ion_blob, IonPyBytes, IonType.BLOB) update_record_and_verify_type(driver, ion_bool, IonPyBool, IonType.BOOL) update_record_and_verify_type(driver, ion_decimal, IonPyDecimal, IonType.DECIMAL) update_record_and_verify_type(driver, ion_float, IonPyFloat, IonType.FLOAT) update_record_and_verify_type(driver, ion_int, IonPyInt, IonType.INT) update_record_and_verify_type(driver, ion_list, IonPyList, IonType.LIST) update_record_and_verify_type(driver, ion_null, IonPyNull, IonType.NULL) update_record_and_verify_type(driver, ion_sexp, IonPyList, IonType.SEXP) update_record_and_verify_type(driver, ion_string, IonPyText, IonType.STRING) update_record_and_verify_type(driver, ion_struct, IonPyDict, IonType.STRUCT) update_record_and_verify_type(driver, ion_symbol, IonPySymbol, IonType.SYMBOL) update_record_and_verify_type(driver, ion_timestamp, IonPyTimestamp, IonType.TIMESTAMP) update_record_and_verify_type(driver, ion_null_clob, IonPyNull, IonType.CLOB) update_record_and_verify_type(driver, ion_null_blob, IonPyNull, IonType.BLOB) update_record_and_verify_type(driver, ion_null_bool, IonPyNull, IonType.BOOL) update_record_and_verify_type(driver, ion_null_decimal, IonPyNull, IonType.DECIMAL) update_record_and_verify_type(driver, ion_null_float, IonPyNull, IonType.FLOAT) update_record_and_verify_type(driver, ion_null_int, IonPyNull, IonType.INT) update_record_and_verify_type(driver, ion_null_list, IonPyNull, IonType.LIST) update_record_and_verify_type(driver, ion_null_sexp, IonPyNull, IonType.SEXP) update_record_and_verify_type(driver, ion_null_string, IonPyNull, IonType.STRING) update_record_and_verify_type(driver, ion_null_struct, IonPyNull, IonType.STRUCT) update_record_and_verify_type(driver, ion_null_symbol, IonPyNull, IonType.SYMBOL) update_record_and_verify_type(driver, ion_null_timestamp, IonPyNull, IonType.TIMESTAMP) delete_table(driver, TABLE_NAME)
def _adjust_sids(annotations=()): if is_binary and isinstance(obj, SymbolToken): return SymbolToken(obj.text, 10 + len(annotations)) return obj
( b'\x6C\x43\xA4\x0F\xE0\x82\x82\x87\x80\x9E\xC6\x03\xE8', # The last three octets represent 1000d-6 e_timestamp(_ts( 2016, 2, 2, 0, 0, 30, 1000, off_hours=-7, precision=TimestampPrecision.SECOND )), ), ( b'\x6C\x43\xA4\x0F\xE0\x82\x82\x87\x80\x9E\xC6\x03\xE8', # The last three octets represent 1000d-6 e_timestamp(_ts( 2016, 2, 2, 0, 0, 30, 1000, off_hours=-7, precision=TimestampPrecision.SECOND, fractional_precision=6 )), ), (b'\x7F', e_symbol()), (b'\x70', e_symbol(SYMBOL_ZERO_TOKEN)), (b'\x71\x02', e_symbol(SymbolToken(None, 2))), (b'\x7A' + b'\xFF' * 10, e_symbol(SymbolToken(None, 0xFFFFFFFFFFFFFFFFFFFF))), (b'\x8F', e_string()), (b'\x80', e_string(u'')), (b'\x84\xf0\x9f\x92\xa9', e_string(u'\U0001F4A9')), (b'\x88$ion_1_0', e_string(u'$ion_1_0')), (b'\x9F', e_clob()), (b'\x90', e_clob(b'')), (b'\x94\xf0\x9f\x92\xa9', e_clob(b'\xf0\x9f\x92\xa9')), (b'\xAF', e_blob()), (b'\xA0', e_blob(b'')), (b'\xA4\xf0\x9f\x92\xa9', e_blob(b'\xf0\x9f\x92\xa9')),