Esempio n. 1
0
 def decode_message(schema_id, payload):
     _AvroStringStore().get_reader(
         reader_id_key=schema_id,
         writer_id_key=schema_id
     ).decode(
         encoded_message=payload
     )
Esempio n. 2
0
        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], {}
Esempio n. 3
0
 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
Esempio n. 4
0
        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], {}
Esempio n. 5
0
 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 = {}
Esempio n. 7
0
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 = {}
Esempio n. 8
0
 def decode_message(schema_id, payload):
     _AvroStringStore().get_reader(
         reader_id_key=schema_id,
         writer_id_key=schema_id).decode(encoded_message=payload)
Esempio n. 9
0
 def encode_message(schema_id, payload_data):
     _AvroStringStore().get_writer(schema_id).encode(
         message_avro_representation=payload_data)
Esempio n. 10
0
 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
     )
Esempio n. 11
0
 def _avro_string_writer(self):
     """get the writer from store if already exists"""
     return _AvroStringStore().get_writer(self.schema_id)
Esempio n. 12
0
 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
Esempio n. 13
0
 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
Esempio n. 14
0
 def encode_message(schema_id, payload_data):
     _AvroStringStore().get_writer(schema_id).encode(
         message_avro_representation=payload_data
     )
Esempio n. 15
0
 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)
Esempio n. 16
0
 def _avro_string_writer(self):
     """get the writer from store if already exists"""
     return _AvroStringStore().get_writer(self.schema_id)