Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_addition(self):
result = 'add', '', [('a', 'b')]
swapped = 'remove', '', [('a', 'b')]
assert next(swap([result])) == swapped
result = 'remove', 'a.b', [('c', 'd')]
swapped = 'add', 'a.b', [('c', 'd')]
assert next(swap([result])) == swapped
def test_changes(self):
result = 'change', '', ('a', 'b')
swapped = 'change', '', ('b', 'a')
assert next(swap([result])) == swapped
patched = dict(current_joined)
if patched["_version"] != target_version:
for history_document in history_documents:
entry_version = history_document["entry_version"]
if entry_version == "removed" or entry_version >= target_version:
if history_document["method_name"] == "add":
patched = "remove"
elif history_document["method_name"] == "remove":
patched = history_document["changes"]
break
else:
diff = dictdiffer.swap(history_document["changes"])
patched = dictdiffer.patch(diff, patched)
else:
break
return patched
patched = deepcopy(current)
# Sort the changes by descending timestamp.
async for change in db.history.find({"kind.id": kind_id}, sort=[("created_at", -1)]):
if change["kind"]["version"] == "removed" or change["kind"]["version"] > version:
reverted_history_ids.append(change["_id"])
if change["method_name"] == "remove":
patched = change["diff"]
elif change["method_name"] == "create":
patched = None
else:
diff = dictdiffer.swap(change["diff"])
patched = dictdiffer.patch(diff, patched)
else:
break
if current == {}:
current = None
return current, patched, reverted_history_ids
patched = deepcopy(current)
# Sort the changes by descending timestamp.
for change in db.history.find({"otu.id": otu_id}, sort=[("otu.version", -1)]):
if change["otu"]["version"] == "removed" or change["otu"]["version"] > version:
reverted_history_ids.append(change["_id"])
if change["method_name"] == "remove":
patched = change["diff"]
elif change["method_name"] == "create":
patched = None
else:
diff = dictdiffer.swap(change["diff"])
patched = dictdiffer.patch(diff, patched)
else:
break
if current == {}:
current = None
return current, patched, reverted_history_ids
patched = deepcopy(current)
# Sort the changes by descending timestamp.
async for change in db.history.find({"virus.id": virus_id}, sort=[("created_at", -1)]):
if change["virus"]["version"] == "removed" or change["virus"]["version"] > version:
reverted_history_ids.append(change["_id"])
if change["method_name"] == "remove":
patched = change["diff"]
elif change["method_name"] == "create":
patched = None
else:
diff = dictdiffer.swap(change["diff"])
patched = dictdiffer.patch(diff, patched)
else:
break
if current == {}:
current = None
return current, patched, reverted_history_ids