You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage.md
+31-29Lines changed: 31 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ It's worth pointing out that `jdiff` is focused on the comparison of the two obj
11
11
12
12
## exact_match
13
13
14
-
Check type `exact_match` is concerned with the value of the elements within the data structure. The key-value pairs should match between the reference and comparison data. A diff is generated between the two data sets and tested to see if all the keys and values match.
14
+
Check type `exact_match` is concerned with the value of the elements within the data structure. The key-value pairs should match between the reference and comparison data. A diff is generated between the two data sets and tested to see whether all the keys and values match.
15
15
16
-
As some outputs might be too verbose or include fields that constantly change (e.g. interface counter), it is possible to exclude a portion of data traversed by JMESPath by defining a keys exclusion list.
16
+
As some outputs might be too verbose or include fields that constantly change (e.g., interface counter), it is possible to exclude a portion of data traversed by JMESPath by defining a key's exclusion list.
17
17
18
18
19
19
Examples:
@@ -102,9 +102,9 @@ Use the evaluate method to return the result.
102
102
False)
103
103
```
104
104
105
-
As we can see, we return a tuple containing a diff between the pre and post data as well as a boolean for the overall test result. In this case a difference has been found so the status of the test is `False`.
105
+
As we can see, we return a tuple containing a diff between the pre and post data as well as a boolean for the overall test result. In this case a difference has been found, so the status of the test is `False`.
106
106
107
-
Let's see a better way to run `exact_match` for this specific case. Because there is a lot of extra key value pairs, some of which change all the time, we are only interested in `interfaceStatus`, so we can use a utility of jdiff: `extract_data_from_json`, which can extract the value from the keys we are interested in and discard the rest.
107
+
Let's see a better way to run `exact_match` for this specific case. Because there are a lot of extra key value pairs, some of which change all the time, we are interested only in `interfaceStatus`. So we can use a utility of jdiff: `extract_data_from_json`, which can extract the value from the keys we are interested in and discard the rest.
@@ -121,13 +121,13 @@ Let's see a better way to run `exact_match` for this specific case. Because ther
121
121
False)
122
122
```
123
123
124
-
In this case, we only want to compare the value of a single key, the `interfaceStatus` key, so we define the jmespath logic to take the name and the interfaceStatus values from the all the interface objects in the data object.
124
+
In this case, we only want to compare the value of a single key, the `interfaceStatus` key. So we define the JMESPath logic to take the name and the interfaceStatus values from all the interface objects in the data object.
125
125
126
-
This type of logic to extract keys and value from the object is called anchor logic and more [here](#extra_value_from_json).
126
+
This type of logic to extract keys and value from the object is called anchor logic. Find more about anchor logic[here](#extra_value_from_json).
127
127
128
128
### Tolerance
129
129
130
-
The `tolerance` test checks for the deviation between the value or count between the reference and comparison values. A `tolerance` is defined and passed to the check along with the comparison and reference values.
130
+
The `tolerance` test checks for the deviation between the value or count of the reference and comparison values. A `tolerance` is defined and passed to the check along with the comparison and reference values.
131
131
132
132
The `tolerance` argument must be a `float > 0`. The calculation is percentage based, and the test of the values may be +/- the `tolerance` percentage.
133
133
@@ -190,7 +190,7 @@ Let's have a look at a couple of examples:
190
190
... }
191
191
>>> my_check = CheckType.create("tolerance")
192
192
```
193
-
We will define a jmespath search for the values we want to test and extract from the reference and comparison objects.
193
+
We will define a JMESPath search for the values we want to test and extract from the reference and comparison objects.
@@ -231,13 +231,13 @@ Let's increase the tolerance:
231
231
({}, True)
232
232
```
233
233
234
-
This check can test if the difference between two values is within a specified tolerance percentage. It could be useful in cases where values like route metrics or optical power levels fluctuate by a small amount. It might be desirable to treat these values as equal if the deviation is within a given range. You can pass in the result of len() to count the number of objects returned within your data.
234
+
This check can test whether the difference between two values is within a specified tolerance percentage. It could be useful in cases where values like route metrics or optical power levels fluctuate by a small amount. It might be desirable to treat these values as equal if the deviation is within a given range. You can pass in the result of len() to count the number of objects returned within your data.
235
235
236
-
### Parameter match
236
+
### Parameter Match
237
237
238
238
The `parameter_match` check provides a way to test key/value pairs against baseline values.
239
239
240
-
The check defines baseline key/value pairs in a Python dictionary. Additionally, mode is set to one of `match` or `no-match`, which specifies if the data should match the baseline, or not.
240
+
The check defines baseline key/value pairs in a Python dictionary. Additionally, mode is set to one of `match` or `no-match`, which specifies whether the data should match the baseline, or not.
mode: no-match - return the keys and values from the test object that do not match the keys and values provides in "params"
299
+
mode: no-match - return the keys and values from the test object that do not match the keys and values provided in "params"
300
300
```python
301
301
>>> my_parameter_match =
302
302
>>> actual_results = my_check.evaluate(
@@ -315,7 +315,7 @@ mode: no-match - return the keys and values from the test object that do not mat
315
315
316
316
The `regex` check type evaluates data against a regular expression passed as an argument to the `evaluate` method. Similarly to `parameter_match` check, the `match`and`no-match` modes are supported.
317
317
318
-
Let's run an example where we want to check the `burnedInAddress` key has a string representing a MAC Address as value
318
+
Let's run an example where we want to check the `burnedInAddress` key has a string representing a MAC address as value.
319
319
320
320
```python
321
321
>>> data = {
@@ -344,21 +344,21 @@ Let's run an example where we want to check the `burnedInAddress` key has a stri
@@ -371,7 +371,7 @@ The `operator` check is a collection of more specific checks divided into catego
371
371
372
372
| Przemek: The below isnot very readable? Indented sections are rendered as code blocks. I would suggest naming these groups "categories"or"groups"and explaing that each of the names is the name of the check that needs to be passed as the argument.
373
373
374
-
#### `in` operators
374
+
#### `in` Operators
375
375
376
376
377
377
1. is-in: Check if the specified element string value is included in a given list of strings.
@@ -386,35 +386,37 @@ The `operator` check is a collection of more specific checks divided into catego
386
386
-in-range: [20, 70]
387
387
check if value isinrange between 20and70
388
388
389
+
|Dwight: delete the space between 5and comma in#4, below?
390
+
389
391
4. not-range: Check if the value of a specified element is outside of a given numeric range.
390
392
-not-range: [5 , 40]
391
393
checks if value isnotinrange between 5and40
392
394
393
-
#### `bool` operators
395
+
#### `bool` Operators
394
396
395
397
1. all-same: Check ifall content values for the specified element are the same. It can also be used to compare all content values against another specified element.
396
398
-all-same: flap-count
397
-
checks ifall values of node <flap-count>in given path is same ornot.
399
+
checks ifall values of node <flap-count>in given path are same ornot.
398
400
399
-
#### `str` operators
401
+
#### `str` Operators
400
402
401
-
1. contains: determinesif an element string value contains the provided test-string value.
403
+
1. contains: Determinesif an element string value contains the provided test-string value.
402
404
- contains: "underlay"
403
405
checks if"underlay"is present in given data ornot.
404
406
405
-
2. not-contains: determinesif an element string value does not contain the provided test-string value.
407
+
2. not-contains: Determinesif an element string value does not contain the provided test-string value.
406
408
-not-contains: "overlay"
407
409
checks if"overlay"is present in given node ornot.
408
410
409
-
#### `int`, `float` operators
411
+
#### `int`, `float` Operators
410
412
411
413
1. is-gt: Check if the value of a specified element is greater than a given numeric value.
412
414
-is-gt: 2
413
-
checks if value should be greater than 2
415
+
checks if value is greater than 2
414
416
415
417
2. is-lt: Check if the value of a specified element is lesser than a given numeric value.
0 commit comments