Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes tests for MongoDB 4.4
- Loading branch information
Showing
4 changed files
with
65 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Common functions for framework tests""" | ||
from collections.abc import Mapping | ||
|
||
|
||
def name_sorted(indexes): | ||
"""Sort indexes by name""" | ||
return sorted(indexes, key=lambda x: x['name']) | ||
|
||
|
||
def strip_indexes(indexes): | ||
"""Strip fields from indexes for comparison | ||
Remove fields that may change between MongoDB versions and configurations | ||
""" | ||
# Indexes may be a list or a dict depending on DB driver | ||
if isinstance(indexes, Mapping): | ||
return { | ||
k: {sk: sv for sk, sv in v.items() if sk not in ('ns', 'v')} | ||
for k, v in indexes.items() | ||
} | ||
return [ | ||
{sk: sv for sk, sv in v.items() if sk not in ('ns', 'v')} | ||
for v in indexes | ||
] |
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
Oops, something went wrong.