summaryrefslogtreecommitdiff
path: root/tests/unit/test_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/test_base.py')
-rw-r--r--tests/unit/test_base.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/unit/test_base.py b/tests/unit/test_base.py
index 137f480..1e4cb7b 100644
--- a/tests/unit/test_base.py
+++ b/tests/unit/test_base.py
@@ -78,13 +78,15 @@ class TestRESTManager:
class TestRESTObject:
def test_instantiate(self, fake_gitlab, fake_manager):
- obj = FakeObject(fake_manager, {"foo": "bar"})
+ attrs = {"foo": "bar"}
+ obj = FakeObject(fake_manager, attrs)
- assert {"foo": "bar"} == obj._attrs
+ assert attrs == obj._attrs
assert {} == obj._updated_attrs
assert obj._create_managers() is None
assert fake_manager == obj.manager
assert fake_gitlab == obj.manager.gitlab
+ assert str(obj) == f"{type(obj)} => {attrs}"
def test_instantiate_non_dict(self, fake_gitlab, fake_manager):
with pytest.raises(gitlab.exceptions.GitlabParsingError):
@@ -159,6 +161,7 @@ class TestRESTObject:
obj1 = FakeObject(fake_manager, {"id": "foo"})
obj2 = FakeObject(fake_manager, {"id": "foo", "other_attr": "bar"})
assert obj1 == obj2
+ assert len(set((obj1, obj2))) == 1
def test_equality_custom_id(self, fake_manager):
class OtherFakeObject(FakeObject):
@@ -177,3 +180,12 @@ class TestRESTObject:
obj1 = FakeObject(fake_manager, {"attr1": "foo"})
obj2 = FakeObject(fake_manager, {"attr1": "bar"})
assert obj1 != obj2
+ assert len(set((obj1, obj2))) == 2
+
+ def test_repr(self, fake_manager):
+ attrs = {"attr1": "foo"}
+ obj = FakeObject(fake_manager, attrs)
+ assert repr(obj) == "<FakeObject id:None>"
+
+ FakeObject._id_attr = None
+ assert repr(obj) == "<FakeObject>"