This is an automated email from the ASF dual-hosted git repository. rskraba pushed a commit to branch branch-1.9 in repository https://gitbox.apache.org/repos/asf/avro.git
commit 78f26ccb3fef97bda59250cf19ff9e9c5f2104bf Author: Michael A. Smith <[email protected]> AuthorDate: Sat Oct 26 21:27:12 2019 -0400 AVRO-2578: Support Both Capitalizations of Parse (#666) * AVRO-2578: Provide Parse in Both Capitalizations * AVRO-2578: Normalize Calls to Parse * AVRO-2578: Test Both Schema Parse Capitalizations * AVRO-2578: Test Both Capitalizations of Protocol.Parse * AVRO-2578: Add Deprecation Warnings for Capital-P Parse * AVRO-2578: Fix Tests for Py3.5 --- lang/py3/avro/datafile.py | 6 +- lang/py3/avro/ipc.py | 14 +- lang/py3/avro/protocol.py | 10 +- lang/py3/avro/schema.py | 11 +- lang/py3/avro/tests/av_bench.py | 2 +- lang/py3/avro/tests/gen_interop_data.py | 24 ++- lang/py3/avro/tests/sample_http_client.py | 2 +- lang/py3/avro/tests/sample_http_server.py | 2 +- lang/py3/avro/tests/test_datafile.py | 8 +- lang/py3/avro/tests/test_io.py | 30 +-- lang/py3/avro/tests/test_ipc.py | 2 +- lang/py3/avro/tests/test_normalization.py | 280 ++++++++++++++-------------- lang/py3/avro/tests/test_protocol.py | 22 ++- lang/py3/avro/tests/test_schema.py | 35 ++-- lang/py3/avro/tests/test_script.py | 2 +- lang/py3/avro/tests/txsample_http_client.py | 2 +- lang/py3/avro/tests/txsample_http_server.py | 2 +- lang/py3/avro/tool.py | 40 ++-- lang/py3/scripts/avro | 2 +- 19 files changed, 266 insertions(+), 230 deletions(-) diff --git a/lang/py3/avro/datafile.py b/lang/py3/avro/datafile.py index 1e9b3fa..8746ef7 100644 --- a/lang/py3/avro/datafile.py +++ b/lang/py3/avro/datafile.py @@ -57,7 +57,7 @@ SYNC_SIZE = 16 SYNC_INTERVAL = 1000 * SYNC_SIZE # Schema of the container header: -META_SCHEMA = schema.Parse(""" +META_SCHEMA = schema.parse(""" { "type": "record", "name": "org.apache.avro.file.Header", "fields": [{ @@ -164,7 +164,7 @@ class DataFileWriter(object): # get schema used to write existing file schema_from_file = dfr.GetMeta('avro.schema').decode('utf-8') self.SetMeta('avro.schema', schema_from_file) - self.datum_writer.writer_schema = schema.Parse(schema_from_file) + self.datum_writer.writer_schema = schema.parse(schema_from_file) # seek to the end of the file and prepare for writing writer.seek(0, 2) @@ -364,7 +364,7 @@ class DataFileReader(object): # get ready to read self._block_count = 0 self.datum_reader.writer_schema = ( - schema.Parse(self.GetMeta(SCHEMA_KEY).decode('utf-8'))) + schema.parse(self.GetMeta(SCHEMA_KEY).decode('utf-8'))) def __enter__(self): return self diff --git a/lang/py3/avro/ipc.py b/lang/py3/avro/ipc.py index f5d376d..22b9b11 100644 --- a/lang/py3/avro/ipc.py +++ b/lang/py3/avro/ipc.py @@ -47,19 +47,19 @@ def LoadResource(name): HANDSHAKE_REQUEST_SCHEMA_JSON = LoadResource('HandshakeRequest.avsc') HANDSHAKE_RESPONSE_SCHEMA_JSON = LoadResource('HandshakeResponse.avsc') -HANDSHAKE_REQUEST_SCHEMA = schema.Parse(HANDSHAKE_REQUEST_SCHEMA_JSON) -HANDSHAKE_RESPONSE_SCHEMA = schema.Parse(HANDSHAKE_RESPONSE_SCHEMA_JSON) +HANDSHAKE_REQUEST_SCHEMA = schema.parse(HANDSHAKE_REQUEST_SCHEMA_JSON) +HANDSHAKE_RESPONSE_SCHEMA = schema.parse(HANDSHAKE_RESPONSE_SCHEMA_JSON) HANDSHAKE_REQUESTOR_WRITER = avro_io.DatumWriter(HANDSHAKE_REQUEST_SCHEMA) HANDSHAKE_REQUESTOR_READER = avro_io.DatumReader(HANDSHAKE_RESPONSE_SCHEMA) HANDSHAKE_RESPONDER_WRITER = avro_io.DatumWriter(HANDSHAKE_RESPONSE_SCHEMA) HANDSHAKE_RESPONDER_READER = avro_io.DatumReader(HANDSHAKE_REQUEST_SCHEMA) -META_SCHEMA = schema.Parse('{"type": "map", "values": "bytes"}') +META_SCHEMA = schema.parse('{"type": "map", "values": "bytes"}') META_WRITER = avro_io.DatumWriter(META_SCHEMA) META_READER = avro_io.DatumReader(META_SCHEMA) -SYSTEM_ERROR_SCHEMA = schema.Parse('["string"]') +SYSTEM_ERROR_SCHEMA = schema.parse('["string"]') AVRO_RPC_MIME = 'avro/binary' @@ -225,7 +225,7 @@ class BaseRequestor(object, metaclass=abc.ABCMeta): elif match == 'CLIENT': # Client's side hash mismatch: self._remote_protocol = \ - protocol.Parse(handshake_response['serverProtocol']) + protocol.parse(handshake_response['serverProtocol']) self._remote_hash = handshake_response['serverHash'] self._send_protocol = False return True @@ -233,7 +233,7 @@ class BaseRequestor(object, metaclass=abc.ABCMeta): elif match == 'NONE': # Neither client nor server match: self._remote_protocol = \ - protocol.Parse(handshake_response['serverProtocol']) + protocol.parse(handshake_response['serverProtocol']) self._remote_hash = handshake_response['serverHash'] self._send_protocol = True return False @@ -415,7 +415,7 @@ class Responder(object, metaclass=abc.ABCMeta): client_protocol = handshake_request.get('clientProtocol') remote_protocol = self.get_protocol_cache(client_hash) if remote_protocol is None and client_protocol is not None: - remote_protocol = protocol.Parse(client_protocol) + remote_protocol = protocol.parse(client_protocol) self.set_protocol_cache(client_hash, remote_protocol) # evaluate remote's guess of the local protocol diff --git a/lang/py3/avro/protocol.py b/lang/py3/avro/protocol.py index 30834da..8ee721c 100644 --- a/lang/py3/avro/protocol.py +++ b/lang/py3/avro/protocol.py @@ -24,6 +24,7 @@ Protocol implementation. import hashlib import json import logging +import warnings from types import MappingProxyType from avro import schema @@ -375,7 +376,7 @@ def ProtocolFromJSONData(json_data): ) -def Parse(json_string): +def parse(json_string): """Constructs a Protocol from its JSON descriptor in text form. Args: @@ -395,3 +396,10 @@ def Parse(json_string): % (json_string, exn)) return ProtocolFromJSONData(json_data) + +def Parse(json_string): + """Deprecated implementation of parse.""" + warnings.warn("`Parse` is deprecated in avro 1.10. " + "Please use `parse` (lowercase) instead.", + DeprecationWarning) + return parse(json_string) diff --git a/lang/py3/avro/schema.py b/lang/py3/avro/schema.py index 9fbe8e5..2bfaa3b 100644 --- a/lang/py3/avro/schema.py +++ b/lang/py3/avro/schema.py @@ -42,6 +42,7 @@ import abc import json import logging import re +import warnings from types import MappingProxyType logger = logging.getLogger(__name__) @@ -1217,7 +1218,7 @@ def SchemaFromJSONData(json_data, names=None): # ------------------------------------------------------------------------------ -def Parse(json_string): +def parse(json_string): """Constructs a Schema from its JSON descriptor in text form. Args: @@ -1241,3 +1242,11 @@ def Parse(json_string): # construct the Avro Schema object return SchemaFromJSONData(json_data, names) + + +def Parse(json_string): + """Deprecated implementation of parse.""" + warnings.warn("`Parse` is deprecated in avro 1.10. " + "Please use `parse` (lowercase) instead.", + DeprecationWarning) + return parse(json_string) diff --git a/lang/py3/avro/tests/av_bench.py b/lang/py3/avro/tests/av_bench.py index 88cbafb..d4baca2 100644 --- a/lang/py3/avro/tests/av_bench.py +++ b/lang/py3/avro/tests/av_bench.py @@ -62,7 +62,7 @@ def Write(nrecords): ] } """ - schema = avro.schema.Parse(schema_s) + schema = avro.schema.parse(schema_s) writer = avro.io.DatumWriter(schema) with open(FILENAME, 'wb') as out: diff --git a/lang/py3/avro/tests/gen_interop_data.py b/lang/py3/avro/tests/gen_interop_data.py index c76f2c2..f3ee9be 100644 --- a/lang/py3/avro/tests/gen_interop_data.py +++ b/lang/py3/avro/tests/gen_interop_data.py @@ -19,8 +19,10 @@ # limitations under the License. import sys +from pathlib import Path from avro import datafile, io, schema +from avro.datafile import NULL_CODEC DATUM = { 'intField': 12, @@ -29,7 +31,7 @@ DATUM = { 'boolField': True, 'floatField': 1234.0, 'doubleField': -1234.0, - 'bytesField': '12312adf', + 'bytesField': b'12312adf', 'nullField': None, 'arrayField': [5.0, 0.0, 12.0], 'mapField': {'a': {'label': 'a'}, 'bee': {'label': 'cee'}}, @@ -43,11 +45,17 @@ DATUM = { } -if __name__ == "__main__": - interop_schema = schema.Parse(open(sys.argv[1], 'r').read()) - writer = open(sys.argv[2], 'wb') +def generate(schema_file, output_path): + interop_schema = schema.parse(open(schema_file, 'r').read()) datum_writer = io.DatumWriter() - # NB: not using compression - dfw = datafile.DataFileWriter(writer, datum_writer, interop_schema) - dfw.append(DATUM) - dfw.close() + for codec in datafile.VALID_CODECS: + filename = 'py3' + if codec != NULL_CODEC: + filename += '_' + codec + with Path(output_path, filename).with_suffix('.avro').open('wb') as writer, \ + datafile.DataFileWriter(writer, datum_writer, interop_schema, codec) as dfw: + dfw.append(DATUM) + + +if __name__ == "__main__": + generate(sys.argv[1], sys.argv[2]) diff --git a/lang/py3/avro/tests/sample_http_client.py b/lang/py3/avro/tests/sample_http_client.py index 47212a1..379389a 100644 --- a/lang/py3/avro/tests/sample_http_client.py +++ b/lang/py3/avro/tests/sample_http_client.py @@ -47,7 +47,7 @@ MAIL_PROTOCOL_JSON = """\ } } """ -MAIL_PROTOCOL = protocol.Parse(MAIL_PROTOCOL_JSON) +MAIL_PROTOCOL = protocol.parse(MAIL_PROTOCOL_JSON) SERVER_HOST = 'localhost' SERVER_PORT = 9090 diff --git a/lang/py3/avro/tests/sample_http_server.py b/lang/py3/avro/tests/sample_http_server.py index 72518be..22aaf6f 100644 --- a/lang/py3/avro/tests/sample_http_server.py +++ b/lang/py3/avro/tests/sample_http_server.py @@ -48,7 +48,7 @@ MAIL_PROTOCOL_JSON = """\ } } """ -MAIL_PROTOCOL = protocol.Parse(MAIL_PROTOCOL_JSON) +MAIL_PROTOCOL = protocol.parse(MAIL_PROTOCOL_JSON) SERVER_ADDRESS = ('localhost', 9090) class MailResponder(ipc.Responder): diff --git a/lang/py3/avro/tests/test_datafile.py b/lang/py3/avro/tests/test_datafile.py index aa4042f..2ab1ab0 100644 --- a/lang/py3/avro/tests/test_datafile.py +++ b/lang/py3/avro/tests/test_datafile.py @@ -144,7 +144,7 @@ class TestDataFile(unittest.TestCase): logging.debug('Creating data file %r', file_path) with open(file_path, 'wb') as writer: datum_writer = io.DatumWriter() - schema_object = schema.Parse(writer_schema) + schema_object = schema.parse(writer_schema) with datafile.DataFileWriter( writer=writer, datum_writer=datum_writer, @@ -193,7 +193,7 @@ class TestDataFile(unittest.TestCase): logging.debug('Creating data file %r', file_path) with open(file_path, 'wb') as writer: datum_writer = io.DatumWriter() - schema_object = schema.Parse(writer_schema) + schema_object = schema.parse(writer_schema) with datafile.DataFileWriter( writer=writer, datum_writer=datum_writer, @@ -239,7 +239,7 @@ class TestDataFile(unittest.TestCase): with open(file_path, 'wb') as writer: datum_writer = io.DatumWriter() sample_schema, sample_datum = SCHEMAS_TO_VALIDATE[1] - schema_object = schema.Parse(sample_schema) + schema_object = schema.parse(sample_schema) with datafile.DataFileWriter(writer, datum_writer, schema_object) as dfw: dfw.append(sample_datum) self.assertTrue(writer.closed) @@ -260,7 +260,7 @@ class TestDataFile(unittest.TestCase): with open(file_path, 'wb') as writer: datum_writer = io.DatumWriter() sample_schema, sample_datum = SCHEMAS_TO_VALIDATE[1] - schema_object = schema.Parse(sample_schema) + schema_object = schema.parse(sample_schema) with datafile.DataFileWriter(writer, datum_writer, schema_object) as dfw: dfw.SetMeta('test.string', 'foo') dfw.SetMeta('test.number', '1') diff --git a/lang/py3/avro/tests/test_io.py b/lang/py3/avro/tests/test_io.py index 2fcd689..cbd2219 100644 --- a/lang/py3/avro/tests/test_io.py +++ b/lang/py3/avro/tests/test_io.py @@ -97,7 +97,7 @@ DEFAULT_VALUE_EXAMPLES = ( '{"A": 5}', {'A': 5}), ) -LONG_RECORD_SCHEMA = schema.Parse(""" +LONG_RECORD_SCHEMA = schema.parse(""" { "type": "record", "name": "Test", @@ -149,7 +149,7 @@ def check_binary_encoding(number_type): logging.debug('Datum: %d', datum) logging.debug('Correct Encoding: %s', hex_encoding) - writer_schema = schema.Parse('"%s"' % number_type.lower()) + writer_schema = schema.parse('"%s"' % number_type.lower()) writer, encoder, datum_writer = write_datum(datum, writer_schema) writer.seek(0) hex_val = avro_hexlify(writer) @@ -167,7 +167,7 @@ def check_skip_number(number_type): logging.debug('Value to Skip: %d', value_to_skip) # write the value to skip and a known value - writer_schema = schema.Parse('"%s"' % number_type.lower()) + writer_schema = schema.parse('"%s"' % number_type.lower()) writer, encoder, datum_writer = write_datum(value_to_skip, writer_schema) datum_writer.write(VALUE_TO_READ, encoder) @@ -198,7 +198,7 @@ class TestIO(unittest.TestCase): for example_schema, datum in SCHEMAS_TO_VALIDATE: logging.debug('Schema: %r', example_schema) logging.debug('Datum: %r', datum) - validated = avro_io.Validate(schema.Parse(example_schema), datum) + validated = avro_io.Validate(schema.parse(example_schema), datum) logging.debug('Valid: %s', validated) if validated: passed += 1 self.assertEqual(passed, len(SCHEMAS_TO_VALIDATE)) @@ -209,7 +209,7 @@ class TestIO(unittest.TestCase): logging.debug('Schema: %s', example_schema) logging.debug('Datum: %s', datum) - writer_schema = schema.Parse(example_schema) + writer_schema = schema.parse(example_schema) writer, encoder, datum_writer = write_datum(datum, writer_schema) round_trip_datum = read_datum(writer, writer_schema) @@ -247,10 +247,10 @@ class TestIO(unittest.TestCase): promotable_schemas = ['"int"', '"long"', '"float"', '"double"'] incorrect = 0 for i, ws in enumerate(promotable_schemas): - writer_schema = schema.Parse(ws) + writer_schema = schema.parse(ws) datum_to_write = 219 for rs in promotable_schemas[i + 1:]: - reader_schema = schema.Parse(rs) + reader_schema = schema.parse(rs) writer, enc, dw = write_datum(datum_to_write, writer_schema) datum_read = read_datum(writer, writer_schema, reader_schema) logging.debug('Writer: %s Reader: %s', writer_schema, reader_schema) @@ -259,12 +259,12 @@ class TestIO(unittest.TestCase): self.assertEqual(incorrect, 0) def testUnknownSymbol(self): - writer_schema = schema.Parse("""\ + writer_schema = schema.parse("""\ {"type": "enum", "name": "Test", "symbols": ["FOO", "BAR"]}""") datum_to_write = 'FOO' - reader_schema = schema.Parse("""\ + reader_schema = schema.parse("""\ {"type": "enum", "name": "Test", "symbols": ["BAR", "BAZ"]}""") @@ -280,7 +280,7 @@ class TestIO(unittest.TestCase): correct = 0 for field_type, default_json, default_datum in DEFAULT_VALUE_EXAMPLES: - reader_schema = schema.Parse("""\ + reader_schema = schema.parse("""\ {"type": "record", "name": "Test", "fields": [{"name": "H", "type": %s, "default": %s}]} """ % (field_type, default_json)) @@ -296,7 +296,7 @@ class TestIO(unittest.TestCase): writer_schema = LONG_RECORD_SCHEMA datum_to_write = LONG_RECORD_DATUM - reader_schema = schema.Parse("""\ + reader_schema = schema.parse("""\ {"type": "record", "name": "Test", "fields": [{"name": "H", "type": "int"}]}""") @@ -310,7 +310,7 @@ class TestIO(unittest.TestCase): writer_schema = LONG_RECORD_SCHEMA datum_to_write = LONG_RECORD_DATUM - reader_schema = schema.Parse("""\ + reader_schema = schema.parse("""\ {"type": "record", "name": "Test", "fields": [{"name": "E", "type": "int"}, {"name": "F", "type": "int"}]}""") @@ -325,7 +325,7 @@ class TestIO(unittest.TestCase): writer_schema = LONG_RECORD_SCHEMA datum_to_write = LONG_RECORD_DATUM - reader_schema = schema.Parse("""\ + reader_schema = schema.parse("""\ {"type": "record", "name": "Test", "fields": [{"name": "F", "type": "int"}, {"name": "E", "type": "int"}]}""") @@ -337,7 +337,7 @@ class TestIO(unittest.TestCase): self.assertEqual(datum_to_read, datum_read) def testTypeException(self): - writer_schema = schema.Parse("""\ + writer_schema = schema.parse("""\ {"type": "record", "name": "Test", "fields": [{"name": "F", "type": "int"}, {"name": "E", "type": "int"}]}""") @@ -346,7 +346,7 @@ class TestIO(unittest.TestCase): avro_io.AvroTypeException, write_datum, datum_to_write, writer_schema) def testUnionSchemaSpecificity(self): - union_schema = schema.Parse(""" + union_schema = schema.parse(""" [{ "type" : "record", "name" : "A", diff --git a/lang/py3/avro/tests/test_ipc.py b/lang/py3/avro/tests/test_ipc.py index 20eee1a..fa23d3c 100644 --- a/lang/py3/avro/tests/test_ipc.py +++ b/lang/py3/avro/tests/test_ipc.py @@ -75,7 +75,7 @@ ECHO_PROTOCOL_JSON = """ """ -ECHO_PROTOCOL = protocol.Parse(ECHO_PROTOCOL_JSON) +ECHO_PROTOCOL = protocol.parse(ECHO_PROTOCOL_JSON) class EchoResponder(ipc.Responder): diff --git a/lang/py3/avro/tests/test_normalization.py b/lang/py3/avro/tests/test_normalization.py index 148bfc0..f464dd7 100644 --- a/lang/py3/avro/tests/test_normalization.py +++ b/lang/py3/avro/tests/test_normalization.py @@ -20,7 +20,7 @@ import unittest -from avro.schema import Parse +from avro.schema import parse from avro.schemanormalization import Fingerprint, FingerprintAlgorithmNames, ToParsingCanonicalForm @@ -29,119 +29,119 @@ class TestSchemaNormalization(unittest.TestCase): def testCanonicalization1(self): pre='"float"' post='"float"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization2(self): pre='{"type": "float"}' post='"float"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization3(self): pre='"int"' post='"int"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization4(self): pre='{"type": "int"}' post='"int"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization5(self): pre='"double"' post='"double"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization6(self): pre='{"type": "double"}' post='"double"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization7(self): pre='"null"' post='"null"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization8(self): pre='{"type": "null"}' post='"null"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization9(self): pre='"bytes"' post='"bytes"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization10(self): pre='{"type": "bytes"}' post='"bytes"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization11(self): pre='"long"' post='"long"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization12(self): pre='{"type": "long"}' post='"long"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization13(self): pre='"boolean"' post='"boolean"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization14(self): pre='{"type": "boolean"}' post='"boolean"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization15(self): pre='"string"' post='"string"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization16(self): pre='{"type": "string"}' post='"string"' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization17(self): pre='{"type": "fixed", "name": "Test", "size": 1}' post='{"name":"Test","type":"fixed","size":1}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -155,21 +155,21 @@ class TestSchemaNormalization(unittest.TestCase): } """ post='{"name":"org.apache.hadoop.avro.MyFixed","type":"fixed","size":1}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization19(self): pre='{"type": "enum", "name": "Test", "symbols": ["A", "B"]}' post='{"name":"Test","type":"enum","symbols":["A","B"]}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization20(self): pre='{"type": "array", "items": "long"}' post='{"type":"array","items":"long"}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -182,14 +182,14 @@ class TestSchemaNormalization(unittest.TestCase): """ post=('{"type":"array","items":{"name":"Test' '","type":"enum","symbols":["A","B"]}}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization22(self): pre='{"type": "map", "values": "long"}' post='{"type":"map","values":"long"}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -202,14 +202,14 @@ class TestSchemaNormalization(unittest.TestCase): """ post=('{"type":"map","values":{"name":"Test"' ',"type":"enum","symbols":["A","B"]}}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) def testCanonicalization24(self): pre='["string", "null", "long"]' post='["string","null","long"]' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -222,7 +222,7 @@ class TestSchemaNormalization(unittest.TestCase): } """ post='{"name":"Test","type":"record","fields":[{"name":"f","type":"long"}]}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -235,7 +235,7 @@ class TestSchemaNormalization(unittest.TestCase): } """ post='{"name":"Test","type":"record","fields":[{"name":"f","type":"long"}]}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -253,7 +253,7 @@ class TestSchemaNormalization(unittest.TestCase): post=('{"name":"Node","type":"record","fields":[{"na' 'me":"label","type":"string"},{"name":"childre' 'n","type":{"type":"array","items":"Node"}}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -280,7 +280,7 @@ class TestSchemaNormalization(unittest.TestCase): post=('{"name":"Lisp","type":"record","fields":[{"name":"value","type' '":["null","string",{"name":"Cons","type":"record","fields":[{"' 'name":"car","type":"Lisp"},{"name":"cdr","type":"Lisp"}]}]}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -310,7 +310,7 @@ class TestSchemaNormalization(unittest.TestCase): '":"clientProtocol","type":["null","string"]},{"name":"se' 'rverHash","type":"org.apache.avro.ipc.MD5"},{"name":"met' 'a","type":["null",{"type":"map","values":"bytes"}]}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -346,7 +346,7 @@ class TestSchemaNormalization(unittest.TestCase): 'ring"]},{"name":"serverHash","type":["null",{"name":"org.ap' 'ache.avro.ipc.MD5","type":"fixed","size":16}]},{"name":"met' 'a","type":["null",{"type":"map","values":"bytes"}]}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -415,7 +415,7 @@ class TestSchemaNormalization(unittest.TestCase): '"recordField","type":{"name":"org.apache.avro.Node","type":"reco' 'rd","fields":[{"name":"label","type":"string"},{"name":"children' '","type":{"type":"array","items":"org.apache.avro.Node"}}]}}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -436,7 +436,7 @@ class TestSchemaNormalization(unittest.TestCase): post=('{"name":"ipAddr","type":"record","fields":[{"name"' ':"addr","type":[{"name":"IPv6","type":"fixed","siz' 'e":16},{"name":"IPv4","type":"fixed","size":4}]}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -451,7 +451,7 @@ class TestSchemaNormalization(unittest.TestCase): """ post=('{"name":"TestDoc","type":"record","fiel' 'ds":[{"name":"name","type":"string"}]}') - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -460,7 +460,7 @@ class TestSchemaNormalization(unittest.TestCase): {"type": "enum", "name": "Test", "symbols": ["A", "B"], "doc": "Doc String"} """ post='{"name":"Test","type":"enum","symbols":["A","B"]}' - pre_schema = Parse(pre) + pre_schema = parse(pre) canonical_form = ToParsingCanonicalForm(pre_schema) self.assertEqual(canonical_form, post) @@ -487,7 +487,7 @@ class TestSchemaFingerprinting(unittest.TestCase): def testUnsupportedFingerprintAlgorithmRaisesValueError(self): schema='"int"' algorithm='UNKNOWN' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) with self.assertRaises(ValueError) as context: Fingerprint(normal_form, algorithm) @@ -497,7 +497,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"int"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='8f5c393f1ad57572' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -507,7 +507,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"int"' algorithm='md5' expected_hex_fingerprint='ef524ea1b91e73173d938ade36c1db32' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -517,7 +517,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"int"' algorithm='sha256' expected_hex_fingerprint='3f2b87a9fe7cc9b13835598c3981cd45e3e355309e5090aa0933d7becb6fba45' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -527,7 +527,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "int"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='8f5c393f1ad57572' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -537,7 +537,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "int"}' algorithm='md5' expected_hex_fingerprint='ef524ea1b91e73173d938ade36c1db32' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -547,7 +547,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "int"}' algorithm='sha256' expected_hex_fingerprint='3f2b87a9fe7cc9b13835598c3981cd45e3e355309e5090aa0933d7becb6fba45' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -557,7 +557,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"float"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='90d7a83ecb027c4d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -567,7 +567,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"float"' algorithm='md5' expected_hex_fingerprint='50a6b9db85da367a6d2df400a41758a6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -577,7 +577,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"float"' algorithm='sha256' expected_hex_fingerprint='1e71f9ec051d663f56b0d8e1fc84d71aa56ccfe9fa93aa20d10547a7abeb5cc0' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -587,7 +587,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "float"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='90d7a83ecb027c4d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -597,7 +597,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "float"}' algorithm='md5' expected_hex_fingerprint='50a6b9db85da367a6d2df400a41758a6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -607,7 +607,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "float"}' algorithm='sha256' expected_hex_fingerprint='1e71f9ec051d663f56b0d8e1fc84d71aa56ccfe9fa93aa20d10547a7abeb5cc0' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -617,7 +617,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"long"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='b71df49344e154d0' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -627,7 +627,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"long"' algorithm='md5' expected_hex_fingerprint='e1dd9a1ef98b451b53690370b393966b' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -637,7 +637,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"long"' algorithm='sha256' expected_hex_fingerprint='c32c497df6730c97fa07362aa5023f37d49a027ec452360778114cf427965add' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -647,7 +647,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "long"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='b71df49344e154d0' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -657,7 +657,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "long"}' algorithm='md5' expected_hex_fingerprint='e1dd9a1ef98b451b53690370b393966b' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -667,7 +667,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "long"}' algorithm='sha256' expected_hex_fingerprint='c32c497df6730c97fa07362aa5023f37d49a027ec452360778114cf427965add' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -677,7 +677,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"double"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='7e95ab32c035758e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -687,7 +687,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"double"' algorithm='md5' expected_hex_fingerprint='bfc71a62f38b99d6a93690deeb4b3af6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -697,7 +697,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"double"' algorithm='sha256' expected_hex_fingerprint='730a9a8c611681d7eef442e03c16c70d13bca3eb8b977bb403eaff52176af254' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -707,7 +707,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "double"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='7e95ab32c035758e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -717,7 +717,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "double"}' algorithm='md5' expected_hex_fingerprint='bfc71a62f38b99d6a93690deeb4b3af6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -727,7 +727,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "double"}' algorithm='sha256' expected_hex_fingerprint='730a9a8c611681d7eef442e03c16c70d13bca3eb8b977bb403eaff52176af254' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -737,7 +737,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"bytes"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='651920c3da16c04f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -747,7 +747,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"bytes"' algorithm='md5' expected_hex_fingerprint='b462f06cb909be57c85008867784cde6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -757,7 +757,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"bytes"' algorithm='sha256' expected_hex_fingerprint='9ae507a9dd39ee5b7c7e285da2c0846521c8ae8d80feeae5504e0c981d53f5fa' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -767,7 +767,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "bytes"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='651920c3da16c04f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -777,7 +777,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "bytes"}' algorithm='md5' expected_hex_fingerprint='b462f06cb909be57c85008867784cde6' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -787,7 +787,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "bytes"}' algorithm='sha256' expected_hex_fingerprint='9ae507a9dd39ee5b7c7e285da2c0846521c8ae8d80feeae5504e0c981d53f5fa' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -797,7 +797,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"string"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='c70345637248018f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -807,7 +807,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"string"' algorithm='md5' expected_hex_fingerprint='095d71cf12556b9d5e330ad575b3df5d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -817,7 +817,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"string"' algorithm='sha256' expected_hex_fingerprint='e9e5c1c9e4f6277339d1bcde0733a59bd42f8731f449da6dc13010a916930d48' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -827,7 +827,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "string"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='c70345637248018f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -837,7 +837,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "string"}' algorithm='md5' expected_hex_fingerprint='095d71cf12556b9d5e330ad575b3df5d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -847,7 +847,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "string"}' algorithm='sha256' expected_hex_fingerprint='e9e5c1c9e4f6277339d1bcde0733a59bd42f8731f449da6dc13010a916930d48' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -857,7 +857,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"boolean"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='64f7d4a478fc429f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -867,7 +867,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"boolean"' algorithm='md5' expected_hex_fingerprint='01f692b30d4a1c8a3e600b1440637f8f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -877,7 +877,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"boolean"' algorithm='sha256' expected_hex_fingerprint='a5b031ab62bc416d720c0410d802ea46b910c4fbe85c50a946ccc658b74e677e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -887,7 +887,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "boolean"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='64f7d4a478fc429f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -897,7 +897,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "boolean"}' algorithm='md5' expected_hex_fingerprint='01f692b30d4a1c8a3e600b1440637f8f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -907,7 +907,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "boolean"}' algorithm='sha256' expected_hex_fingerprint='a5b031ab62bc416d720c0410d802ea46b910c4fbe85c50a946ccc658b74e677e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -917,7 +917,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"null"' algorithm='CRC-64-AVRO' expected_hex_fingerprint='8a8f25cce724dd63' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -927,7 +927,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"null"' algorithm='md5' expected_hex_fingerprint='9b41ef67651c18488a8b08bb67c75699' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -937,7 +937,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='"null"' algorithm='sha256' expected_hex_fingerprint='f072cbec3bf8841871d4284230c5e983dc211a56837aed862487148f947d1a1f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -947,7 +947,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "null"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='8a8f25cce724dd63' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -957,7 +957,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "null"}' algorithm='md5' expected_hex_fingerprint='9b41ef67651c18488a8b08bb67c75699' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -967,7 +967,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "null"}' algorithm='sha256' expected_hex_fingerprint='f072cbec3bf8841871d4284230c5e983dc211a56837aed862487148f947d1a1f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -977,7 +977,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "fixed", "name": "Test", "size": 1}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='6869897b4049355b' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -987,7 +987,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "fixed", "name": "Test", "size": 1}' algorithm='md5' expected_hex_fingerprint='db01bc515fcfcd2d4be82ed385288261' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -997,7 +997,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "fixed", "name": "Test", "size": 1}' algorithm='sha256' expected_hex_fingerprint='f527116a6f44455697e935afc31dc60ad0f95caf35e1d9c9db62edb3ffeb9170' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1014,7 +1014,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='fadbd138e85bdf45' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1031,7 +1031,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='d74b3726484422711c465d49e857b1ba' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1048,7 +1048,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='28e493a44771cecc5deca4bd938cdc3d5a24cfe1f3760bc938fa1057df6334fc' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1058,7 +1058,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "enum", "name": "Test", "symbols": ["A", "B"]}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='03a2f2c2e27f7a16' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1068,7 +1068,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "enum", "name": "Test", "symbols": ["A", "B"]}' algorithm='md5' expected_hex_fingerprint='d883f2a9b16ed085fcc5e4ca6c8f6ed1' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1078,7 +1078,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "enum", "name": "Test", "symbols": ["A", "B"]}' algorithm='sha256' expected_hex_fingerprint='9b51286144f87ce5aebdc61ca834379effa5a41ce6ac0938630ff246297caca8' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1088,7 +1088,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "array", "items": "long"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='715e2ea28bc91654' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1098,7 +1098,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "array", "items": "long"}' algorithm='md5' expected_hex_fingerprint='c1c387e8d6a58f0df749b698991b1f43' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1108,7 +1108,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "array", "items": "long"}' algorithm='sha256' expected_hex_fingerprint='f78e954167feb23dcb1ce01e8463cebf3408e0a4259e16f24bd38f6d0f1d578b' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1123,7 +1123,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='10d9ade1fa3a0387' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1138,7 +1138,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='cfc7b861c7cfef082a6ef082948893fa' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1153,7 +1153,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='0d8edd49d7f7e9553668f133577bc99f842852b55d9f84f1f7511e4961aa685c' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1163,7 +1163,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "map", "values": "long"}' algorithm='CRC-64-AVRO' expected_hex_fingerprint='6f74f4e409b1334e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1173,7 +1173,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "map", "values": "long"}' algorithm='md5' expected_hex_fingerprint='32b3f1a3177a0e73017920f00448b56e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1183,7 +1183,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "map", "values": "long"}' algorithm='sha256' expected_hex_fingerprint='b8fad07d458971a07692206b8a7cf626c86c62fe6bcff7c1b11bc7295de34853' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1198,7 +1198,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='df2ab0626f6b812d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1213,7 +1213,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='c588da6ba99701c41e73fd30d23f994e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1228,7 +1228,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='3886747ed1669a8af476b549e97b34222afb2fed5f18bb27c6f367ea0351a576' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1238,7 +1238,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='["string", "null", "long"]' algorithm='CRC-64-AVRO' expected_hex_fingerprint='65a5be410d687566' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1248,7 +1248,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='["string", "null", "long"]' algorithm='md5' expected_hex_fingerprint='b11cf95f0a55dd55f9ee515a37bf937a' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1258,7 +1258,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='["string", "null", "long"]' algorithm='sha256' expected_hex_fingerprint='ed8d254116441bb35e237ad0563cf5432b8c975334bd222c1ee84609435d95bb' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1274,7 +1274,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='ed94e5f5e6eb588e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1290,7 +1290,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='69531a03db788afe353244cd049b1e6d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1306,7 +1306,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='9670f15a8f96d23e92830d00b8bd57275e02e3e173ffef7c253c170b6beabeb8' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1322,7 +1322,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='ed94e5f5e6eb588e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1338,7 +1338,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='69531a03db788afe353244cd049b1e6d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1354,7 +1354,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='9670f15a8f96d23e92830d00b8bd57275e02e3e173ffef7c253c170b6beabeb8' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1373,7 +1373,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='52cba544c3e756b7' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1392,7 +1392,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='99625b0cc02050363e89ef66b0f406c9' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1411,7 +1411,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='65d80dc8c95c98a9671d92cf0415edfabfee2cb058df2138606656cd6ae4dc59' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1439,7 +1439,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='68d91a23eda0b306' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1467,7 +1467,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='9e1d0d15b52789fcb8e3a88b53059d5f' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1495,7 +1495,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='e5ce4f4a15ce19fa1047cfe16a3b0e13a755db40f00f23284fdd376fc1c7dd21' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1523,7 +1523,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='b96ad79e5a7c5757' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1551,7 +1551,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='4c822af2e17eecd92422827eede97f5b' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1579,7 +1579,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='2b2f7a9b22991fe0df9134cb6b5ff7355343e797aaea337e0150e20f3a35800e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1612,7 +1612,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='00feee01de4ea50e' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1645,7 +1645,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='afe529d01132daab7f4e2a6663e7a2f5' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1678,7 +1678,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='a303cbbfe13958f880605d70c521a4b7be34d9265ac5a848f25916a67b11d889' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1735,7 +1735,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='e82c0a93a6a0b5a4' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1792,7 +1792,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='994fea1a1be7ff8603cbe40c3bc7e4ca' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1849,7 +1849,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='cccfd6e3f917cf53b0f90c206342e6703b0d905071f724a1c1f85b731c74058d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1871,7 +1871,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='8d961b4e298a1844' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1893,7 +1893,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='45d85c69b353a99b93d7c4f2fcf0c30d' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1915,7 +1915,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='6f6fc8f685a4f07d99734946565d63108806d55a8620febea047cf52cb0ac181' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1932,7 +1932,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='0e6660f02bcdc109' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1949,7 +1949,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='f2da75f5131f5ab80629538287b8beb2' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -1966,7 +1966,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='0b3644f7aa5ca2fc4bad93ca2d3609c12aa9dbda9c15e68b34c120beff08e7b9' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -1978,7 +1978,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='CRC-64-AVRO' expected_hex_fingerprint='03a2f2c2e27f7a16' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(16) @@ -1990,7 +1990,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='md5' expected_hex_fingerprint='d883f2a9b16ed085fcc5e4ca6c8f6ed1' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -2002,7 +2002,7 @@ class TestSchemaFingerprinting(unittest.TestCase): """ algorithm='sha256' expected_hex_fingerprint='9b51286144f87ce5aebdc61ca834379effa5a41ce6ac0938630ff246297caca8' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) @@ -2012,7 +2012,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "int"}' algorithm='MD5' # Java compatible name alias expected_hex_fingerprint='ef524ea1b91e73173d938ade36c1db32' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(32) @@ -2022,7 +2022,7 @@ class TestSchemaFingerprinting(unittest.TestCase): schema='{"type": "int"}' algorithm='SHA-256' # Java compatible name alias expected_hex_fingerprint='3f2b87a9fe7cc9b13835598c3981cd45e3e355309e5090aa0933d7becb6fba45' - pre_schema = Parse(schema) + pre_schema = parse(schema) normal_form = ToParsingCanonicalForm(pre_schema) fingerprint = Fingerprint(normal_form, algorithm) actual_hex_fingerprint = "".join(format(b, "02x") for b in fingerprint).zfill(64) diff --git a/lang/py3/avro/tests/test_protocol.py b/lang/py3/avro/tests/test_protocol.py index 7dabd59..d372973 100644 --- a/lang/py3/avro/tests/test_protocol.py +++ b/lang/py3/avro/tests/test_protocol.py @@ -24,6 +24,7 @@ Test the protocol parsing logic. import logging import traceback import unittest +import unittest.mock from avro import protocol @@ -399,6 +400,12 @@ VALID_EXAMPLES = [e for e in EXAMPLES if e.valid] class TestProtocol(unittest.TestCase): + @unittest.mock.patch('avro.protocol.warnings.warn') + def test_Parse_is_deprecated(self, warn): + """Capital-P Parse is deprecated.""" + protocol.Parse(HELLO_WORLD.protocol_string) + self.assertEqual(warn.call_count, 1) + def testParse(self): correct = 0 for iexample, example in enumerate(EXAMPLES): @@ -406,7 +413,7 @@ class TestProtocol(unittest.TestCase): 'Parsing protocol #%d:\n%s', iexample, example.protocol_string) try: - parsed = protocol.Parse(example.protocol_string) + parsed = protocol.parse(example.protocol_string) if example.valid: correct += 1 else: @@ -431,13 +438,13 @@ class TestProtocol(unittest.TestCase): % (correct, len(EXAMPLES))) def testInnerNamespaceSet(self): - proto = protocol.Parse(HELLO_WORLD.protocol_string) + proto = protocol.parse(HELLO_WORLD.protocol_string) self.assertEqual(proto.namespace, 'com.acme') greeting_type = proto.type_map['com.acme.Greeting'] self.assertEqual(greeting_type.namespace, 'com.acme') def testInnerNamespaceNotRendered(self): - proto = protocol.Parse(HELLO_WORLD.protocol_string) + proto = protocol.parse(HELLO_WORLD.protocol_string) self.assertEqual('com.acme.Greeting', proto.types[0].fullname) self.assertEqual('Greeting', proto.types[0].name) # but there shouldn't be 'namespace' rendered to json on the inner type @@ -450,9 +457,9 @@ class TestProtocol(unittest.TestCase): """ num_correct = 0 for example in VALID_EXAMPLES: - proto = protocol.Parse(example.protocol_string) + proto = protocol.parse(example.protocol_string) try: - protocol.Parse(str(proto)) + protocol.parse(str(proto)) except ProtocolParseException: logging.debug('Failed to reparse protocol:\n%s', example.protocol_string) @@ -460,7 +467,6 @@ class TestProtocol(unittest.TestCase): logging.debug('Successfully reparsed protocol:\n%s', example.protocol_string) num_correct += 1 - fail_msg = ( 'Cast to string success on %d out of %d protocols' % (num_correct, len(VALID_EXAMPLES))) @@ -475,8 +481,8 @@ class TestProtocol(unittest.TestCase): """ num_correct = 0 for example in VALID_EXAMPLES: - original_protocol = protocol.Parse(example.protocol_string) - round_trip_protocol = protocol.Parse(str(original_protocol)) + original_protocol = protocol.parse(example.protocol_string) + round_trip_protocol = protocol.parse(str(original_protocol)) if original_protocol == round_trip_protocol: num_correct += 1 diff --git a/lang/py3/avro/tests/test_schema.py b/lang/py3/avro/tests/test_schema.py index 2d82904..dc16513 100644 --- a/lang/py3/avro/tests/test_schema.py +++ b/lang/py3/avro/tests/test_schema.py @@ -24,6 +24,7 @@ Test the schema parsing logic. import logging import traceback import unittest +import unittest.mock from avro import schema @@ -450,7 +451,7 @@ VALID_EXAMPLES = [e for e in EXAMPLES if e.valid] class TestSchema(unittest.TestCase): def testCorrectRecursiveExtraction(self): - parsed = schema.Parse(""" + parsed = schema.parse(""" { "type": "record", "name": "X", @@ -466,7 +467,7 @@ class TestSchema(unittest.TestCase): """) logging.debug('Parsed schema:\n%s', parsed) logging.debug('Fields: %s', parsed.fields) - t = schema.Parse(str(parsed.fields[0].type)) + t = schema.parse(str(parsed.fields[0].type)) # If we've made it this far, the subschema was reasonably stringified; # it could be reparsed. self.assertEqual("X", t.fields[0].type.name) @@ -480,16 +481,22 @@ class TestSchema(unittest.TestCase): '{"type": "map", "values": "int"}', '["null", "int"]', ] - for case in (schema.Parse(case) for case in cases): + for case in (schema.parse(case) for case in cases): self.assertRaises(AttributeError, lambda: case.name) self.assertEqual(getattr(case, "name", "default"), "default") - def testParse(self): + @unittest.mock.patch('avro.schema.warnings.warn') + def test_Parse_is_deprecated(self, warn): + """Capital-P Parse is deprecated.""" + schema.Parse(PRIMITIVE_EXAMPLES[0].schema_string) + self.assertEqual(warn.call_count, 1) + + def test_parse(self): correct = 0 for iexample, example in enumerate(EXAMPLES): logging.debug('Testing example #%d\n%s', iexample, example.schema_string) try: - schema.Parse(example.schema_string) + schema.parse(example.schema_string) if example.valid: correct += 1 else: @@ -520,8 +527,8 @@ class TestSchema(unittest.TestCase): """ correct = 0 for example in VALID_EXAMPLES: - schema_data = schema.Parse(example.schema_string) - schema.Parse(str(schema_data)) + schema_data = schema.parse(example.schema_string) + schema.parse(str(schema_data)) correct += 1 fail_msg = "Cast to string success on %d out of %d schemas" % \ @@ -537,8 +544,8 @@ class TestSchema(unittest.TestCase): """ correct = 0 for example in VALID_EXAMPLES: - original_schema = schema.Parse(example.schema_string) - round_trip_schema = schema.Parse(str(original_schema)) + original_schema = schema.parse(example.schema_string) + round_trip_schema = schema.parse(str(original_schema)) if original_schema == round_trip_schema: correct += 1 debug_msg = "%s: ROUND TRIP SUCCESS" % example.name @@ -592,7 +599,7 @@ class TestSchema(unittest.TestCase): def testDocAttributes(self): correct = 0 for example in DOC_EXAMPLES: - original_schema = schema.Parse(example.schema_string) + original_schema = schema.parse(example.schema_string) if original_schema.doc is not None: correct += 1 if original_schema.type == 'record': @@ -607,8 +614,8 @@ class TestSchema(unittest.TestCase): correct = 0 props = {} for example in OTHER_PROP_EXAMPLES: - original_schema = schema.Parse(example.schema_string) - round_trip_schema = schema.Parse(str(original_schema)) + original_schema = schema.parse(example.schema_string) + round_trip_schema = schema.parse(str(original_schema)) self.assertEqual(original_schema.other_props,round_trip_schema.other_props) if original_schema.type == "record": field_props = 0 @@ -641,8 +648,8 @@ class TestSchema(unittest.TestCase): "fields": [{"name": "foo", "type": "int"}, {"name": "foo", "type": "string"}] }""" with self.assertRaises(schema.SchemaParseException) as e: - schema.Parse(schema_string) - self.assertRegexpMatches(str(e.exception), 'Duplicate.*field name.*foo') + schema.parse(schema_string) + self.assertRegex(str(e.exception), 'Duplicate.*field name.*foo') # ------------------------------------------------------------------------------ diff --git a/lang/py3/avro/tests/test_script.py b/lang/py3/avro/tests/test_script.py index 647d346..4d317dd 100644 --- a/lang/py3/avro/tests/test_script.py +++ b/lang/py3/avro/tests/test_script.py @@ -118,7 +118,7 @@ class TestCat(unittest.TestCase): @staticmethod def WriteAvroFile(file_path): - schema = avro.schema.Parse(SCHEMA) + schema = avro.schema.parse(SCHEMA) with open(file_path, 'wb') as writer: with avro.datafile.DataFileWriter( writer=writer, diff --git a/lang/py3/avro/tests/txsample_http_client.py b/lang/py3/avro/tests/txsample_http_client.py index f3e573a..a536aa8 100644 --- a/lang/py3/avro/tests/txsample_http_client.py +++ b/lang/py3/avro/tests/txsample_http_client.py @@ -49,7 +49,7 @@ MAIL_PROTOCOL_JSON = """\ } } """ -MAIL_PROTOCOL = protocol.Parse(MAIL_PROTOCOL_JSON) +MAIL_PROTOCOL = protocol.parse(MAIL_PROTOCOL_JSON) SERVER_HOST = 'localhost' SERVER_PORT = 9090 diff --git a/lang/py3/avro/tests/txsample_http_server.py b/lang/py3/avro/tests/txsample_http_server.py index c85f42a..beb1267 100644 --- a/lang/py3/avro/tests/txsample_http_server.py +++ b/lang/py3/avro/tests/txsample_http_server.py @@ -49,7 +49,7 @@ MAIL_PROTOCOL_JSON = """\ } } """ -MAIL_PROTOCOL = protocol.Parse(MAIL_PROTOCOL_JSON) +MAIL_PROTOCOL = protocol.parse(MAIL_PROTOCOL_JSON) SERVER_ADDRESS = ('localhost', 9090) class MailResponder(ipc.Responder): diff --git a/lang/py3/avro/tool.py b/lang/py3/avro/tool.py index 6bfce0d..e3674b2 100644 --- a/lang/py3/avro/tool.py +++ b/lang/py3/avro/tool.py @@ -25,21 +25,21 @@ NOTE: The API for the command-line tool is experimental. import sys import urllib -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from http.server import BaseHTTPRequestHandler, HTTPServer from avro import datafile, io, ipc, protocol class GenericResponder(ipc.Responder): def __init__(self, proto, msg, datum): - proto_json = file(proto, 'r').read() - ipc.Responder.__init__(self, protocol.Parse(proto_json)) + proto_json = open(proto, 'r').read() + ipc.Responder.__init__(self, protocol.parse(proto_json)) self.msg = msg self.datum = datum - def invoke(self, message, request): + def Invoke(self, message, request): if message.name == self.msg: - print >> sys.stderr, "Message: %s Datum: %s" % (message.name, self.datum) + print("Message: %s Datum: %s" % (message.name, self.datum), sys.stderr) # server will shut down after processing a single Avro request global server_should_shutdown server_should_shutdown = True @@ -49,15 +49,15 @@ class GenericHandler(BaseHTTPRequestHandler): def do_POST(self): self.responder = responder call_request_reader = ipc.FramedReader(self.rfile) - call_request = call_request_reader.read_framed_message() - resp_body = self.responder.respond(call_request) + call_request = call_request_reader.Read() + resp_body = self.responder.Respond(call_request) self.send_response(200) self.send_header('Content-Type', 'avro/binary') self.end_headers() resp_writer = ipc.FramedWriter(self.wfile) - resp_writer.write_framed_message(resp_body) + resp_writer.Write(resp_body) if server_should_shutdown: - print >> sys.stderr, "Shutting down server." + print("Shutting down server.", sys.stderr) self.server.force_stop() class StoppableHTTPServer(HTTPServer): @@ -88,15 +88,15 @@ def run_server(uri, proto, msg, datum): print("Port: %s" % server.server_port) sys.stdout.flush() server.allow_reuse_address = True - print >> sys.stderr, "Starting server." + print("Starting server.", sys.stderr) server.serve_forever() def send_message(uri, proto, msg, datum): url_obj = urllib.parse.urlparse(uri) client = ipc.HTTPTransceiver(url_obj.hostname, url_obj.port) - proto_json = file(proto, 'r').read() - requestor = ipc.Requestor(protocol.Parse(proto_json), client) - print(requestor.request(msg, datum)) + proto_json = open(proto, 'r').read() + requestor = ipc.Requestor(protocol.parse(proto_json), client) + print(requestor.Request(msg, datum)) def file_or_stdin(f): if f == "-": @@ -125,10 +125,9 @@ def main(args=sys.argv): datum = None if len(args) > 5: if args[5] == "-file": - reader = open(args[6], 'rb') - datum_reader = io.DatumReader() - dfr = datafile.DataFileReader(reader, datum_reader) - datum = dfr.next() + with open(args[6], 'rb') as reader: + with datafile.DataFileReader(reader, io.DatumReader()) as dfr: + datum = next(dfr) elif args[5] == "-data": print("JSON Decoder not yet implemented.") return 1 @@ -146,10 +145,9 @@ def main(args=sys.argv): datum = None if len(args) > 5: if args[5] == "-file": - reader = open(args[6], 'rb') - datum_reader = io.DatumReader() - dfr = datafile.DataFileReader(reader, datum_reader) - datum = dfr.next() + with open(args[6], 'rb') as reader: + with datafile.DataFileReader(reader, io.DatumReader()) as dfr: + datum = next(dfr) elif args[5] == "-data": print("JSON Decoder not yet implemented.") return 1 diff --git a/lang/py3/scripts/avro b/lang/py3/scripts/avro index 61d6a4f..23daac8 100755 --- a/lang/py3/scripts/avro +++ b/lang/py3/scripts/avro @@ -213,7 +213,7 @@ def write(opts, files): try: with open(opts.schema, 'rt') as f: json_schema = f.read() - writer_schema = schema.Parse(json_schema) + writer_schema = schema.parse(json_schema) out = _open(opts.output, 'wb') except (IOError, OSError) as e: raise AvroError('Cannot open file - %s' % e)
