forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ingest): fix serialization of report to handle nesting (datahub-p…
- Loading branch information
1 parent
13b3db1
commit 1e73b33
Showing
2 changed files
with
79 additions
and
9 deletions.
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,50 @@ | ||
import json | ||
from typing import cast | ||
|
||
from datahub.ingestion.api.source import ( | ||
CapabilityReport, | ||
SourceCapability, | ||
TestConnectionReport, | ||
) | ||
|
||
|
||
def test_basic_capability_report(): | ||
report = TestConnectionReport( | ||
basic_connectivity=CapabilityReport( | ||
capable=True, failure_reason=None, mitigation_message=None | ||
), | ||
capability_report={ | ||
"CONTAINERS": CapabilityReport( | ||
capable=True, failure_reason=None, mitigation_message=None | ||
), | ||
"SCHEMA_METADATA": CapabilityReport( | ||
capable=True, failure_reason=None, mitigation_message=None | ||
), | ||
"DESCRIPTIONS": CapabilityReport( | ||
capable=False, | ||
failure_reason="failed to get descriptions", | ||
mitigation_message="Enable admin privileges for this account.", | ||
), | ||
"DATA_PROFILING": CapabilityReport( | ||
capable=True, failure_reason=None, mitigation_message=None | ||
), | ||
SourceCapability.DOMAINS: CapabilityReport(capable=True), | ||
}, | ||
) | ||
print(report.as_obj()) | ||
foo = cast(dict, report.as_obj()) | ||
assert isinstance(foo, dict) | ||
assert foo["capability_report"]["CONTAINERS"]["capable"] is True | ||
assert foo["capability_report"]["SCHEMA_METADATA"]["capable"] is True | ||
assert foo["capability_report"]["DESCRIPTIONS"]["capable"] is False | ||
assert ( | ||
foo["capability_report"]["DESCRIPTIONS"]["failure_reason"] | ||
== "failed to get descriptions" | ||
) | ||
assert ( | ||
foo["capability_report"]["DESCRIPTIONS"]["mitigation_message"] | ||
== "Enable admin privileges for this account." | ||
) | ||
assert foo["capability_report"]["DOMAINS"]["capable"] is True | ||
|
||
assert isinstance(json.loads(report.as_json()), dict) |