Ejemplo n.º 1
0
class _EncodeTest(_SchemaRegistryAvroTest):
    def __init__(self, arguments):
        super().__init__(arguments)
        self.sync_credential = DefaultAzureCredential()
        self.sync_client = SchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.sync_credential,
        )
        self.sync_encoder = AvroEncoder(client=self.sync_client,
                                        group_name=self.group_name,
                                        auto_register_schemas=True)
        self.async_credential = AsyncDefaultAzureCredential()
        self.async_client = AsyncSchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.async_credential,
        )
        self.async_encoder = AsyncAvroEncoder(client=self.async_client,
                                              group_name=self.group_name,
                                              auto_register_schemas=True)

    async def global_setup(self):
        await super().global_setup()

    async def close(self):
        self.sync_client.close()
        self.sync_credential.close()
        self.sync_encoder.close()
        await self.async_client.close()
        await self.async_credential.close()
        await self.async_encoder.close()
        await super().close()
Ejemplo n.º 2
0
class _GetSchemaTest(_SchemaRegistryTest):
    def __init__(self, arguments):
        super().__init__(arguments)
        self.sync_credential = DefaultAzureCredential()
        self.sync_client = SchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.sync_credential,
        )
        self.async_credential = AsyncDefaultAzureCredential()
        self.async_client = AsyncSchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.async_credential,
        )
        self.schema_id = self._preregister_schema()

    def _preregister_schema(self):
        with self.sync_client as client:
            schema_properties = client.register_schema(self.group_name,
                                                       self.name,
                                                       self.definition,
                                                       self.format)
            return schema_properties.id

    async def global_setup(self):
        await super().global_setup()

    async def close(self):
        self.sync_client.close()
        self.sync_credential.close()
        await self.async_client.close()
        await self.async_credential.close()
        await super().close()
Ejemplo n.º 3
0
class _RegisterTest(_SchemaRegistryTest):
    def __init__(self, arguments):
        super().__init__(arguments)
        self.sync_credential = DefaultAzureCredential()
        self.sync_client = SchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.sync_credential,
        )
        self.async_credential = AsyncDefaultAzureCredential()
        self.async_client = AsyncSchemaRegistryClient(
            fully_qualified_namespace=self.fully_qualified_namespace,
            credential=self.async_credential,
        )

    async def global_setup(self):
        await super().global_setup()

    async def close(self):
        self.sync_client.close()
        self.sync_credential.close()
        await self.async_client.close()
        await self.async_credential.close()
        await super().close()