def decode_message(schema_id, payload): _AvroStringStore().get_reader( reader_id_key=schema_id, writer_id_key=schema_id ).decode( encoded_message=payload )
def setup(): schema_id = SchemaFactory.get_schema_json().schema_id payload_data = SchemaFactory.get_payload_data() payload = _AvroStringStore().get_writer(schema_id).encode( message_avro_representation=payload_data) return [schema_id, payload], {}
def test_get_writer_without_schema(self, schematizer, parameters): registered_schema = schematizer.schemas.register_schema( body=parameters ).result() schema_id = registered_schema.schema_id store = _AvroStringStore() store.get_writer(schema_id) assert schema_id in store._writer_cache
def setup(): schema_id = SchemaFactory.get_schema_json().schema_id payload_data = SchemaFactory.get_payload_data() payload = _AvroStringStore().get_writer(schema_id).encode( message_avro_representation=payload_data ) return [schema_id, payload], {}
def encoded_keys(self): writer = _AvroStringStore().get_writer( id_key="{0}_{1}".format("keys", self.schema_id), avro_schema=self._keys_avro_json ) return writer.encode(message_avro_representation=self.keys)
def cleanup_avro_cache(): # This is needed as _AvroStringStore is a Singleton and doesn't delete # its cache even after an instance gets destroyed. We manually delete # the cache so that last test module's schemas do not affect current tests. _AvroStringStore()._reader_cache = {} _AvroStringStore()._writer_cache = {}
def decode_message(schema_id, payload): _AvroStringStore().get_reader( reader_id_key=schema_id, writer_id_key=schema_id).decode(encoded_message=payload)
def encode_message(schema_id, payload_data): _AvroStringStore().get_writer(schema_id).encode( message_avro_representation=payload_data)
def _avro_string_reader(self): """get the reader from store if already exists""" return _AvroStringStore().get_reader( reader_id_key=self.reader_schema_id, writer_id_key=self.schema_id )
def _avro_string_writer(self): """get the writer from store if already exists""" return _AvroStringStore().get_writer(self.schema_id)
def test_get_reader_with_schema(self, schema_types): schema_id = 5 store = _AvroStringStore() store.get_reader(schema_id, schema_id, schema_types, schema_types) assert (schema_id, schema_id) in store._reader_cache
def test_get_writer_with_schema(self, schema_types): schema_id = 5 store = _AvroStringStore() store.get_writer(schema_id, schema_types) assert schema_id in store._writer_cache
def encode_message(schema_id, payload_data): _AvroStringStore().get_writer(schema_id).encode( message_avro_representation=payload_data )
def _avro_string_reader(self): """get the reader from store if already exists""" return _AvroStringStore().get_reader( reader_id_key=self.reader_schema_id, writer_id_key=self.schema_id)