2025-05-06 10:51:34 -04:00
|
|
|
from unittest.mock import Mock
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from datahub.errors import SdkUsageError
|
|
|
|
from datahub.ingestion.graph.client import DataHubGraph
|
|
|
|
from datahub.sdk.main_client import DataHubClient
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_graph() -> Mock:
|
|
|
|
graph = Mock(spec=DataHubGraph)
|
|
|
|
graph.exists.return_value = False
|
|
|
|
return graph
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def client(mock_graph: Mock) -> DataHubClient:
|
|
|
|
return DataHubClient(graph=mock_graph)
|
|
|
|
|
|
|
|
|
2025-05-09 16:19:50 -04:00
|
|
|
def test_use_assertions_client_fails_if_not_installed(
|
2025-05-06 10:51:34 -04:00
|
|
|
client: DataHubClient, mock_graph: Mock
|
|
|
|
) -> None:
|
|
|
|
mock_graph.exists.return_value = True
|
|
|
|
|
|
|
|
with pytest.raises(
|
|
|
|
SdkUsageError,
|
2025-05-09 16:19:50 -04:00
|
|
|
match="AssertionsClient is not installed, please install it with `pip install acryl-datahub-cloud`",
|
2025-05-06 10:51:34 -04:00
|
|
|
):
|
2025-05-09 16:19:50 -04:00
|
|
|
client.assertions.get_assertions(urn="urn:li:assertion:123")
|