|
| 1 | +import pytest |
| 2 | + |
| 3 | +from unstructured_ingest.processes.connector_registry import ( |
| 4 | + destination_registry, |
| 5 | + source_registry, |
| 6 | +) |
| 7 | + |
| 8 | + |
| 9 | +def test_all_source_connector_configs_json_schema(): |
| 10 | + failed_connectors = [] |
| 11 | + |
| 12 | + for connector_type, connector_entry in source_registry.items(): |
| 13 | + try: |
| 14 | + if connector_entry.connection_config: |
| 15 | + schema = connector_entry.connection_config.model_json_schema() |
| 16 | + assert schema is not None, f"Schema is None for {connector_type} connection_config" |
| 17 | + |
| 18 | + if connector_entry.indexer_config: |
| 19 | + schema = connector_entry.indexer_config.model_json_schema() |
| 20 | + assert schema is not None, f"Schema is None for {connector_type} indexer_config" |
| 21 | + |
| 22 | + if connector_entry.downloader_config: |
| 23 | + schema = connector_entry.downloader_config.model_json_schema() |
| 24 | + assert schema is not None, f"Schema is None for {connector_type} downloader_config" |
| 25 | + |
| 26 | + except Exception as e: |
| 27 | + failed_connectors.append((connector_type, str(e))) |
| 28 | + |
| 29 | + if failed_connectors: |
| 30 | + error_msg = "Failed to generate JSON schema for source connectors:\n" |
| 31 | + for connector_type, error in failed_connectors: |
| 32 | + error_msg += f" - {connector_type}: {error}\n" |
| 33 | + pytest.fail(error_msg) |
| 34 | + |
| 35 | + |
| 36 | +def test_all_destination_connector_configs_json_schema(): |
| 37 | + failed_connectors = [] |
| 38 | + |
| 39 | + for connector_type, connector_entry in destination_registry.items(): |
| 40 | + try: |
| 41 | + if connector_entry.connection_config: |
| 42 | + schema = connector_entry.connection_config.model_json_schema() |
| 43 | + assert schema is not None, f"Schema is None for {connector_type} connection_config" |
| 44 | + |
| 45 | + if connector_entry.uploader_config: |
| 46 | + schema = connector_entry.uploader_config.model_json_schema() |
| 47 | + assert schema is not None, f"Schema is None for {connector_type} uploader_config" |
| 48 | + |
| 49 | + if connector_entry.upload_stager_config: |
| 50 | + schema = connector_entry.upload_stager_config.model_json_schema() |
| 51 | + assert schema is not None, ( |
| 52 | + f"Schema is None for {connector_type} upload_stager_config" |
| 53 | + ) |
| 54 | + |
| 55 | + except Exception as e: |
| 56 | + failed_connectors.append((connector_type, str(e))) |
| 57 | + |
| 58 | + if failed_connectors: |
| 59 | + error_msg = "Failed to generate JSON schema for destination connectors:\n" |
| 60 | + for connector_type, error in failed_connectors: |
| 61 | + error_msg += f" - {connector_type}: {error}\n" |
| 62 | + pytest.fail(error_msg) |
0 commit comments