-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an optimistic conflict resolution mecanism.
The server tries to merge conflicting saves of the same layer. What it does: - use the `If-Unmodified-Since` header to check if changes happened to the stored data ; - Compare the incoming version with its reference version and the latest known version ; - Try to merge with a simple algo (features added on both side, removal on one side…) - If the merge is not possible, return the old "422 Conflict" HTTP response. - If the merge worked, return the merged document, to be updated by the client.
- Loading branch information
1 parent
34ee8e8
commit cad5afc
Showing
5 changed files
with
236 additions
and
19 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
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
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,67 @@ | ||
import pytest | ||
|
||
from umap.utils import merge_features | ||
|
||
|
||
def test_adding_one_element(): | ||
assert merge_features(["A", "B"], ["A", "B", "C"], ["A", "B", "D"]) == [ | ||
"A", | ||
"B", | ||
"C", | ||
"D", | ||
] | ||
|
||
|
||
def test_adding_elements(): | ||
assert merge_features(["A", "B"], ["A", "B", "C", "D"], ["A", "B", "E", "F"]) == [ | ||
"A", | ||
"B", | ||
"C", | ||
"D", | ||
"E", | ||
"F", | ||
] | ||
# Order does not count | ||
assert merge_features(["A", "B"], ["B", "C", "D", "A"], ["A", "B", "E", "F"]) == [ | ||
"B", | ||
"C", | ||
"D", | ||
"A", | ||
"E", | ||
"F", | ||
] | ||
|
||
|
||
def test_adding_one_removing_one(): | ||
assert merge_features(["A", "B"], ["A", "C"], ["A", "B", "D"]) == [ | ||
"A", | ||
"C", | ||
"D", | ||
] | ||
|
||
|
||
def test_removing_same_element(): | ||
# No added element (otherwise we cannot know if "new" elements are old modified | ||
# or old removed and new added). | ||
assert merge_features(["A", "B", "C"], ["A", "B"], ["A", "B"]) == [ | ||
"A", | ||
"B", | ||
] | ||
|
||
|
||
def test_removing_changed_element(): | ||
with pytest.raises(ValueError): | ||
merge_features(["A", "B"], ["A", "C"], ["A"]) | ||
|
||
|
||
def test_changing_removed_element(): | ||
with pytest.raises(ValueError): | ||
merge_features(["A", "B"], ["A"], ["A", "C"]) | ||
|
||
|
||
def test_changing_same_element(): | ||
with pytest.raises(ValueError): | ||
merge_features(["A", "B"], ["A", "D"], ["A", "C"]) | ||
# Order does not count | ||
with pytest.raises(ValueError): | ||
merge_features(["A", "B", "C"], ["B", "D", "A"], ["A", "E", "B"]) |
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
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