summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_base.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-05-02 13:12:11 +0200
committerNejc Habjan <hab.nejc@gmail.com>2021-05-02 13:12:11 +0200
commit796c700cf854b547afb56bb6ea47a5600f437e47 (patch)
treef236a139a844cf055c8fe9769203b481f5380a8a /gitlab/tests/test_base.py
parentb563cdc1a6cd585647fc53722081dceb6f7b4466 (diff)
downloadgitlab-fix/persist-attributes-on-save.tar.gz
fix(base): allow persisting attributes when updating objectfix/persist-attributes-on-save
Diffstat (limited to 'gitlab/tests/test_base.py')
-rw-r--r--gitlab/tests/test_base.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/gitlab/tests/test_base.py b/gitlab/tests/test_base.py
index 1c811cf..986d51f 100644
--- a/gitlab/tests/test_base.py
+++ b/gitlab/tests/test_base.py
@@ -128,11 +128,25 @@ class TestRESTObject:
assert {"foo": "foo", "bar": "bar"} == obj._attrs
assert {} == obj._updated_attrs
- def test_update_attrs_deleted(self, fake_manager):
- obj = FakeObject(fake_manager, {"foo": "foo", "bar": "bar"})
- obj.bar = "baz"
+ @pytest.mark.parametrize(
+ "initial_attrs,persist_attrs,assigned_attr,expected_attrs",
+ [
+ ({"foo": "foo", "bar": "bar"}, None, "baz", {"foo": "foo"}),
+ ({"foo": "foo", "bar": "bar"}, False, "baz", {"foo": "foo"}),
+ ({"foo": "foo", "bar": "bar"}, True, "baz", {"foo": "foo", "bar": "baz"}),
+ ],
+ )
+ def test_update_attrs_deleted(
+ self, fake_manager, initial_attrs, persist_attrs, assigned_attr, expected_attrs
+ ):
+ obj = FakeObject(fake_manager, initial_attrs)
+ obj._attrs["bar"] = assigned_attr
+
+ if persist_attrs is not None:
+ obj.__dict__["_persist_attrs"] = persist_attrs
+
obj._update_attrs({"foo": "foo"})
- assert {"foo": "foo"} == obj._attrs
+ assert expected_attrs == obj._attrs
assert {} == obj._updated_attrs
def test_dir_unique(self, fake_manager):