Skip to content

Commit

Permalink
Rename merge_conflicts in merge_features
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed May 15, 2023
1 parent ae6fd3b commit d0d27d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest

from umap.utils import merge_conflicts
from umap.utils import merge_features


def test_adding_one_element():
assert merge_conflicts(["A", "B"], ["A", "B", "C"], ["A", "B", "D"]) == [
assert merge_features(["A", "B"], ["A", "B", "C"], ["A", "B", "D"]) == [
"A",
"B",
"C",
Expand All @@ -13,7 +13,7 @@ def test_adding_one_element():


def test_adding_elements():
assert merge_conflicts(["A", "B"], ["A", "B", "C", "D"], ["A", "B", "E", "F"]) == [
assert merge_features(["A", "B"], ["A", "B", "C", "D"], ["A", "B", "E", "F"]) == [
"A",
"B",
"C",
Expand All @@ -22,7 +22,7 @@ def test_adding_elements():
"F",
]
# Order does not count
assert merge_conflicts(["A", "B"], ["B", "C", "D", "A"], ["A", "B", "E", "F"]) == [
assert merge_features(["A", "B"], ["B", "C", "D", "A"], ["A", "B", "E", "F"]) == [
"B",
"C",
"D",
Expand All @@ -33,7 +33,7 @@ def test_adding_elements():


def test_adding_one_removing_one():
assert merge_conflicts(["A", "B"], ["A", "C"], ["A", "B", "D"]) == [
assert merge_features(["A", "B"], ["A", "C"], ["A", "B", "D"]) == [
"A",
"C",
"D",
Expand All @@ -43,25 +43,25 @@ def test_adding_one_removing_one():
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_conflicts(["A", "B", "C"], ["A", "B"], ["A", "B"]) == [
assert merge_features(["A", "B", "C"], ["A", "B"], ["A", "B"]) == [
"A",
"B",
]


def test_removing_changed_element():
with pytest.raises(ValueError):
merge_conflicts(["A", "B"], ["A", "C"], ["A"])
merge_features(["A", "B"], ["A", "C"], ["A"])


def test_changing_removed_element():
with pytest.raises(ValueError):
merge_conflicts(["A", "B"], ["A"], ["A", "C"])
merge_features(["A", "B"], ["A"], ["A", "C"])


def test_changing_same_element():
with pytest.raises(ValueError):
merge_conflicts(["A", "B"], ["A", "D"], ["A", "C"])
merge_features(["A", "B"], ["A", "D"], ["A", "C"])
# Order does not count
with pytest.raises(ValueError):
merge_conflicts(["A", "B", "C"], ["B", "D", "A"], ["A", "E", "B"])
merge_features(["A", "B", "C"], ["B", "D", "A"], ["A", "E", "B"])
2 changes: 1 addition & 1 deletion umap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def is_ajax(request):
return request.headers.get("x-requested-with") == "XMLHttpRequest"


def merge_conflicts(reference, latest, entrant):
def merge_features(reference, latest, entrant):

# Just in case (eg. both removed the same element, or changed only metadatas)
if latest == entrant:
Expand Down
4 changes: 2 additions & 2 deletions umap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
UpdateMapPermissionsForm,
)
from .models import DataLayer, Licence, Map, Pictogram, TileLayer
from .utils import get_uri_template, gzip_file, is_ajax, merge_conflicts
from .utils import get_uri_template, gzip_file, is_ajax, merge_features

try:
# python3
Expand Down Expand Up @@ -794,7 +794,7 @@ def merge(self):
latest = json.loads(f.read())

try:
merge_conflicts(
merge_features(
reference["features"], latest["features"], entrant["features"]
)
except ValueError:
Expand Down

0 comments on commit d0d27d1

Please sign in to comment.