Skip to content

Commit

Permalink
rework
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alisafaee committed Sep 18, 2023
1 parent 3379bf3 commit c2e3395
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions tests/core/commands/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_log_dataset_create_simple(mocker):
new_dataset = mocker.MagicMock()
new_dataset.id = "new"
new_dataset.slug = "ds"
new_dataset.title = None
new_dataset.name = None
new_dataset.description = None
new_dataset.derived_from = None
new_dataset.same_as = None
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_log_dataset_create_complex(mocker):
new_dataset.slug = "ds"
new_dataset.derived_from = None
new_dataset.same_as = None
new_dataset.title = "new-title"
new_dataset.name = "new-name"
new_dataset.description = "new-description"
new_dataset.dataset_files = []
new_dataset.creators = [mocker.MagicMock(full_identity="John")]
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_log_dataset_create_complex(mocker):
assert "ds" == entry.id
assert "Dataset 'ds': created" == entry.description

assert "new-title" == entry.details.name_changed
assert "new-name" == entry.details.name_changed
assert "new-description" == entry.details.description_changed
assert ["John"] == entry.details.creators_added
assert not entry.details.files_added
Expand All @@ -217,7 +217,7 @@ def test_log_dataset_add_create(mocker):
new_dataset.slug = "ds"
new_dataset.derived_from = None
new_dataset.same_as = None
new_dataset.title = "new-title"
new_dataset.name = "new-name"
new_dataset.description = "new-description"
new_dataset.dataset_files = [
mocker.MagicMock(date_removed=None, entity=mocker.MagicMock(path="file_a")),
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_log_dataset_add_create(mocker):
assert "ds" == entry.id
assert "Dataset 'ds': created, 2 file(s) added" == entry.description

assert "new-title" == entry.details.name_changed
assert "new-name" == entry.details.name_changed
assert "new-description" == entry.details.description_changed
assert not entry.details.creators_added
assert {"file_b", "file_a"} == set(entry.details.files_added)
Expand All @@ -273,7 +273,7 @@ def test_log_dataset_import(mocker):
new_dataset.id = "new"
new_dataset.slug = "ds"
new_dataset.derived_from = None
new_dataset.title = "new-title"
new_dataset.name = "new-name"
new_dataset.description = "new-description"
new_dataset.same_as = mocker.MagicMock(value="http://renkulab.io/my/dataset")
new_dataset.dataset_files = [
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_log_dataset_import(mocker):
assert "ds" == entry.id
assert "Dataset 'ds': imported, 2 file(s) added" == entry.description

assert "new-title" == entry.details.name_changed
assert "new-name" == entry.details.name_changed
assert "new-description" == entry.details.description_changed
assert not entry.details.creators_added
assert {"file_b", "file_a"} == set(entry.details.files_added)
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_log_dataset_deleted(mocker):
new_dataset = mocker.MagicMock()
new_dataset.id = "new"
new_dataset.slug = "ds"
new_dataset.title = None
new_dataset.name = None
new_dataset.description = None
new_dataset.derived_from = Url(url_id="old")
new_dataset.same_as = None
Expand Down Expand Up @@ -402,7 +402,7 @@ def test_log_dataset_files_removed(mocker):
old_dataset = mocker.MagicMock()
old_dataset.id = "old"
old_dataset.slug = "ds"
old_dataset.title = None
old_dataset.name = None
old_dataset.description = None
old_dataset.derived_from = None
old_dataset.same_as = None
Expand All @@ -415,7 +415,7 @@ def test_log_dataset_files_removed(mocker):
new_dataset = mocker.MagicMock()
new_dataset.id = "new"
new_dataset.slug = "ds"
new_dataset.title = None
new_dataset.name = None
new_dataset.description = None
new_dataset.derived_from = Url(url_id="old")
new_dataset.same_as = None
Expand Down Expand Up @@ -480,7 +480,7 @@ def test_log_dataset_metadata_modified(mocker):
old_dataset = mocker.MagicMock()
old_dataset.id = "old"
old_dataset.slug = "ds"
old_dataset.title = "old-title"
old_dataset.name = "old-name"
old_dataset.description = "old-description"
old_dataset.dataset_files = []
old_dataset.creators = [mocker.MagicMock(full_identity="John")]
Expand All @@ -494,7 +494,7 @@ def test_log_dataset_metadata_modified(mocker):
new_dataset = mocker.MagicMock()
new_dataset.id = "new"
new_dataset.slug = "ds"
new_dataset.title = "new-title"
new_dataset.name = "new-name"
new_dataset.description = "new-description"
new_dataset.derived_from = Url(url_id="old")
new_dataset.same_as = None
Expand Down Expand Up @@ -540,7 +540,7 @@ def _mock_get_by_id(id):
assert "ds" == entry.id
assert "Dataset 'ds': metadata modified" == entry.description

assert "new-title" == entry.details.name_changed
assert "new-name" == entry.details.name_changed
assert "new-description" == entry.details.description_changed
assert not entry.details.files_added
assert not entry.details.files_removed
Expand Down
26 changes: 13 additions & 13 deletions tests/core/commands/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_merge_dataset_tree_local_modified_dataset(mocker):
"""Test merging dataset tree with local modifications."""
dataset = Dataset(id=Dataset.generate_id(uuid4().hex), slug="dataset", name="First")
modified_dataset = dataset.copy()
modified_dataset.update_metadata(title="Modified title")
modified_dataset.update_metadata(name="Modified name")
modified_dataset.derive_from(dataset, creator=None)

local = BTree({"dataset": modified_dataset})
Expand All @@ -59,14 +59,14 @@ def test_merge_dataset_tree_local_modified_dataset(mocker):

merged = merger.merge_btrees(local, remote)
assert "dataset" in merged.keys()
assert "Modified title" == merged["dataset"].title
assert "Modified name" == merged["dataset"].name


def test_merge_dataset_tree_remote_modified_dataset(mocker):
"""Test merging dataset tree with remote modifications."""
dataset = Dataset(id=Dataset.generate_id(uuid4().hex), name="dataset", title="First")
dataset = Dataset(id=Dataset.generate_id(uuid4().hex), slug="dataset", name="First")
modified_dataset = dataset.copy()
modified_dataset.update_metadata(title="Modified title")
modified_dataset.update_metadata(name="Modified name")
modified_dataset.derive_from(dataset, creator=None)

local = BTree({"dataset": dataset})
Expand All @@ -80,20 +80,20 @@ def test_merge_dataset_tree_remote_modified_dataset(mocker):

merged = merger.merge_btrees(local, remote)
assert "dataset" in merged.keys()
assert "Modified title" == merged["dataset"].title
assert "Modified name" == merged["dataset"].name


def test_merge_dataset_tree_both_modified_dataset(mocker):
"""Test merging dataset tree with remote and local modifications."""
dataset = Dataset(id=Dataset.generate_id(uuid4().hex), name="dataset", title="First")
dataset = Dataset(id=Dataset.generate_id(uuid4().hex), slug="dataset", name="First")
modified_local_dataset = dataset.copy()
modified_local_dataset.update_metadata(title="Modified local title")
modified_local_dataset.update_metadata(name="Modified local name")
modified_local_dataset.derive_from(dataset, creator=None)
modified_remote_dataset = dataset.copy()
modified_remote_dataset.update_metadata(title="Modified remote title")
modified_remote_dataset.update_metadata(name="Modified remote name")
modified_remote_dataset.derive_from(dataset, creator=None)

unrelated_dataset = Dataset(id=Dataset.generate_id(uuid4().hex), name="unrelated_dataset", title="unrelated")
unrelated_dataset = Dataset(id=Dataset.generate_id(uuid4().hex), slug="unrelated_dataset", name="unrelated")

all_datasets = [dataset, modified_local_dataset, modified_remote_dataset, unrelated_dataset]

Expand All @@ -109,16 +109,16 @@ def test_merge_dataset_tree_both_modified_dataset(mocker):
mocker.patch("renku.infrastructure.git_merger.communication.prompt", mocker.MagicMock(return_value="l"))
merged = merger.merge_btrees(local, remote)
assert "dataset" in merged.keys()
assert "Modified local title" == merged["dataset"].title
assert "Modified local name" == merged["dataset"].name
assert "unrelated_dataset" in merged.keys()
assert "unrelated" == merged["unrelated_dataset"].title
assert "unrelated" == merged["unrelated_dataset"].name

mocker.patch("renku.infrastructure.git_merger.communication.prompt", mocker.MagicMock(return_value="r"))
merged = merger.merge_btrees(local, remote)
assert "dataset" in merged.keys()
assert "Modified remote title" == merged["dataset"].title
assert "Modified remote name" == merged["dataset"].name
assert "unrelated_dataset" in merged.keys()
assert "unrelated" == merged["unrelated_dataset"].title
assert "unrelated" == merged["unrelated_dataset"].name


def test_merge_plan_tree_non_conflict_plan():
Expand Down

0 comments on commit c2e3395

Please sign in to comment.