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
(DOCSP-53139): Python code example comparison + sample data utilities (#14459)
* Create an implementation plan for Python comparison lib
* Scaffold comparison lib, existing tests pass
* Build out missing functionality, some tests fail
* Fix JSONL splitting bug
* Fix Python 2/3 normalization bugs
* Fix date normalization in parser
* Fix remaining test failure
* Properly handle date time parsing
* Add support for PyMongo Operations Objects
* Handle unordered arrays, PyMongo object ellipsis, search index models
* Handle positional args in Update operation
* Handle datetime comparison in structured text comparisons
* Fix failing test
* Add Python sample data utility
* Remove unneeded implementation plan
* Add sample data in CI workflow
* Use new comparison APIs for agg pipeline examples, fix missing newline in output
* Update README for new utils
* Add missed ComparisonOptions in preferred API, fix missed ellipsis requirements
* Add comprehensive code docs for new utilities
* Apply suggestions from code review
Co-authored-by: cory <115956901+cbullinger@users.noreply.github.com>
* Cleanup based on review feedback
* Switch time series quick start to use comparison lib
* Add a Python formatting tool, format files and add to snip script
---------
Co-authored-by: cory <115956901+cbullinger@users.noreply.github.com>
-**UUIDs and tokens**: `uuid`, `sessionId`, `apiKey`
394
+
-**Auto-generated values**: Any field with dynamic content
395
+
396
+
##### Handle flexible content in output files
397
+
398
+
For output files that truncate the actual output to show only what's relevant
399
+
to our readers, use ellipsis patterns (`...`) in your output files to enable
400
+
flexible content matching. Our tooling automatically detects and handles these
401
+
patterns.
402
+
403
+
###### Shorten string values
404
+
405
+
You can use an ellipsis at the end of a string value to shorten it in the
406
+
example output. This will match any number of characters in the actual return
407
+
after the `...`.
408
+
409
+
In the expected output file, add an ellipsis to the end of a string value:
410
+
411
+
```txt
412
+
{
413
+
plot: 'A young man is accidentally sent 30 years into the past...',
414
+
}
415
+
```
416
+
417
+
This matches the actual output of:
418
+
419
+
```txt
420
+
{
421
+
plot: 'A young man is accidentally sent 30 years into the past in a time-traveling DeLorean invented by his close friend, the maverick scientist Doc Brown.',
422
+
}
423
+
```
424
+
425
+
###### Omit unimportant values for keys
426
+
427
+
If it's not important to show the value or type for a given key at all,
428
+
replace the value with an ellipsis in the expected output file.
429
+
430
+
```txt
431
+
`{_id: ...}`
432
+
```
433
+
434
+
Matches any value for the key `_id` in the actual output.
435
+
436
+
###### Omit any number of keys and values entirely
437
+
438
+
If actual output contains many keys and values that are not necessary to show
439
+
to illustrate an example, add an ellipsis as a standalone line in your
440
+
expected output file:
310
441
311
-
self.assertEqual(expected_output, actual_output)
442
+
```txt
443
+
{
444
+
full_name: 'Carmen Sandiego',
445
+
...
446
+
}
447
+
```
448
+
449
+
Matches actual output that contains any number of additional keys and values
450
+
beyond the `full_name` field.
451
+
452
+
You can also interject standalone `...` lines between properties, similar to:
453
+
454
+
```txt
455
+
{
456
+
full_name: 'Carmen Sandiego',
457
+
...
458
+
address: 'Somewhere in the world...'
459
+
}
460
+
```
461
+
462
+
##### Complete options reference
463
+
464
+
The `ComparisonOptions` object supports these properties:
465
+
466
+
```py
467
+
comparison_type: Optional[str] =None# "ordered", "unordered", or None (auto-select)
468
+
ignore_field_values: Optional[set[str]] =None
469
+
timeout_seconds: int=30
470
+
array_size_threshold: int=50# Max size for unordered backtracking
312
471
```
313
472
314
473
#### Verify print output
@@ -339,6 +498,66 @@ Save the connection string for use in the next step. If needed, see
0 commit comments