mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-07-05 08:02:48 +00:00

### Description Update all other connectors to use the new downstream architecture that was recently introduced for the s3 connector. Closes #1313 and #1311
28 lines
840 B
Python
28 lines
840 B
Python
import pytest
|
|
|
|
from unstructured.ingest.error import (
|
|
DestinationConnectionError,
|
|
PartitionError,
|
|
SourceConnectionError,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("error_class", "exception_type", "error_message"),
|
|
[
|
|
(SourceConnectionError, ValueError, "Simulated connection error"),
|
|
(DestinationConnectionError, RuntimeError, "Simulated connection error"),
|
|
(PartitionError, FileNotFoundError, "Simulated partition error"),
|
|
],
|
|
)
|
|
def test_custom_error_decorator(error_class, exception_type, error_message):
|
|
@error_class.wrap
|
|
def simulate_error():
|
|
raise exception_type(error_message)
|
|
|
|
with pytest.raises(error_class) as context:
|
|
simulate_error()
|
|
|
|
expected_error_string = error_class.error_string.format(error_message)
|
|
assert str(context.value) == expected_error_string
|