-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(python-sdk): DataHubGraph get_aspect should accept empty responses (
- Loading branch information
1 parent
2f95719
commit db182e4
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig | ||
from datahub.metadata.schema_classes import CorpUserEditableInfoClass | ||
|
||
|
||
@patch("datahub.ingestion.graph.client.telemetry_enabled", False) | ||
@patch("datahub.emitter.rest_emitter.DataHubRestEmitter.test_connection") | ||
def test_get_aspect(mock_test_connection): | ||
mock_test_connection.return_value = {} | ||
graph = DataHubGraph(DataHubGraphConfig()) | ||
user_urn = "urn:li:corpuser:foo" | ||
with patch("requests.Session.get") as mock_get: | ||
mock_response = Mock() | ||
mock_response.json = Mock( | ||
return_value={ | ||
"version": 0, | ||
"aspect": {"com.linkedin.identity.CorpUserEditableInfo": {}}, | ||
} | ||
) | ||
mock_get.return_value = mock_response | ||
editable = graph.get_aspect(user_urn, CorpUserEditableInfoClass) | ||
assert editable is not None |