Skip to content

Commit

Permalink
Improved code and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chsou committed Nov 21, 2024
1 parent 1b53e15 commit bbd17c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions c8y_api/model/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,7 @@ def get(self, path: str, default=None):
continue
if hasattr(value, segment):
return value.__getattribute__(segment)
else:
return default
return default
return value

@deprecated
Expand Down Expand Up @@ -497,7 +496,6 @@ def build_object_path(self, object_id: int | str) -> str:
"""
return self.resource + '/' + str(object_id)


@staticmethod
def _map_params(
q=None,
Expand Down
3 changes: 3 additions & 0 deletions tests/model/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def test_complexobject_instantiation_and_formatting():


def test_complexobject_get():
"""Verify that get by path works as expected."""

obj = ComplexTestObject(
field='field value',
Expand All @@ -247,6 +248,8 @@ def test_complexobject_get():
assert obj.get('c8y_complex.a') == obj.c8y_complex.a
assert obj.get('not') is None
assert obj.get('not', 'default') == 'default'
assert obj.get('c8y_complex.not') is None
assert obj.get('c8y_complex.not', 'default') == 'default'


@pytest.mark.parametrize('page_size, num_all, limit, expected', [
Expand Down

0 comments on commit bbd17c5

Please sign in to comment.