Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipeline/src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def to_jsonld(self, include_empty_properties=True, embed_linked_nodes=True, with
data["@id"] = self.id
for property in self.__class__.properties:
value = getattr(self, property.name)
if value or include_empty_properties:
if (value is not None) or include_empty_properties:
if property.multiple:
if value is None:
data[property.path] = value
Expand Down
25 changes: 20 additions & 5 deletions pipeline/tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ def test_issue0069(om):
result = om.sands.ParcellationEntity.by_name("NODa,b")
assert result.abbreviation == "NODa,b"

result = om.sands.CommonCoordinateSpace.by_name("MEBRAINS population-based monkey brain template")
result = om.sands.CommonCoordinateFramework.by_name("MEBRAINS population-based monkey brain template")
assert result.full_name == "MEBRAINS population-based monkey brain template"

assert om.controlled_terms.BiologicalOrder.by_name("rodents") == om.controlled_terms.BiologicalOrder.by_name("Rodentia") != None

# Test with "all=True"
results = om.sands.BrainAtlasVersion.by_name("Julich-Brain Atlas", all=True)
results = om.sands.AnatomicalAtlasVersion.by_name("Julich-Brain Atlas", all=True)
assert len(results) == 30
assert all(r.short_name == "Julich-Brain Atlas" for r in results)
assert len(set(r.id for r in results)) == len(results)
Expand All @@ -332,16 +332,31 @@ def test_issue0069(om):
assert len(results) == 7
assert all("CC" in r.short_name for r in results)


@pytest.mark.parametrize("om", [openminds.latest])
def test_pr0083(om):
# https://github.com/openMetadataInitiative/openMINDS_Python/pull/83
# by_name() should return None consistently
# when no matches are found, regardless of the 'all' parameter

# all=False (default) should return None when no match is found
result = om.controlled_terms.BiologicalOrder.by_name("nonexistent_order_xyz")
assert result is None

# all=True should also return None when no match is found
results = om.controlled_terms.BiologicalOrder.by_name("nonexistent_order_xyz", all=True)
assert results is None
assert results is None


@pytest.mark.parametrize("om", [openminds.latest, openminds.v4])
def test_issue0084(om):
# Properties whose value evaluates to False (e.g., zero)
# are not serialized if using include_empty_properties=False
obj = om.publications.LivePaperSection(name="test", order=0)
data = obj.to_jsonld(include_empty_properties=False)
assert data == {
"@context": {"@vocab": "https://openminds.om-i.org/props/"},
"@type": "https://openminds.om-i.org/types/LivePaperSection",
"name": "test",
"order": 0,
}