jdiff
¶
Initialization file for library.
jdiff.CheckType
¶
Bases: ABC
Check Type Base Abstract Class.
create(check_type)
staticmethod
¶
Factory pattern to get the appropriate CheckType implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check_type
|
str
|
String to define the type of check. |
required |
evaluate(*args, **kwargs)
abstractmethod
¶
Return the result of the evaluation and a boolean True if it passes it or False otherwise.
This method is the one that each CheckType has to implement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
tuple
|
arguments specific to child class implementation |
()
|
**kwargs
|
dict
|
named arguments |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[Dict, bool]
|
Dictionary representing check result, bool indicating if differences are found. |
result(evaluation_result)
staticmethod
¶
Result method implementation. Will return diff data and bool for checking failed result.
jdiff.extract_data_from_json(data, path='*', exclude=None)
¶
Return wanted data from outpdevice data based on the check path. See unit test for complete example.
Get the wanted values to be evaluated if JMESPath expression is defined, otherwise use the entire data if jmespath is not defined in check. This covers the "raw" diff type. Exclude data not desired to compare.
Notes
https://jmespath.org/ shows how JMESPath works.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[Mapping, List]
|
json data structure |
required |
path
|
str
|
JMESPath to extract specific values |
'*'
|
exclude
|
Optional[List]
|
list of keys to exclude |
None
|
Returns: Evaluated data, may be anything depending on JMESPath used.