Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #53 from JR-1991/52-datamodelget-does-not-get-elem…
Browse files Browse the repository at this point in the history
…ent-if-value-is-float0-or-int0

52 datamodelget does not get element if value is float0 or int0
  • Loading branch information
JR-1991 authored Feb 26, 2024
2 parents d4a3667 + 88332eb commit cc2d1e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdRDM/base/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _get_by_meta_path(
query,
)

if reference:
if reference is not None:
references.append(reference)

return references
Expand Down
26 changes: 26 additions & 0 deletions tests/end2end/test_datamodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from sdRDM import DataModel


class TestGetMethod:

def test_get_method_by_meta_with_zeros(self, model_all):
"""Tests whether the get_method_by_meta method returns the correct values"""

# Arrange
dataset = model_all.Root(
multiple_primitives=[0.0, 2.0],
nested_multiple_obj=[
model_all.Nested(float_value=0.0),
model_all.Nested(float_value=2.0),
],
)

# Act
multiple_primitives = dataset.get("multiple_primitives")
nested_multiple_obj = dataset.get("nested_multiple_obj")
nested_multiple_obj_floats = dataset.get("nested_multiple_obj/float_value")

assert multiple_primitives == [[0.0, 2.0]]
assert all(isinstance(obj, model_all.Nested) for obj in nested_multiple_obj[0])
assert all(obj.float_value in [0.0, 2.0] for obj in nested_multiple_obj[0])
assert nested_multiple_obj_floats == [0.0, 2.0]

0 comments on commit cc2d1e2

Please sign in to comment.