Commit e07effe6 authored by Yannick DAYER's avatar Yannick DAYER

Added delayed_attributes tests

parent b0454c18
Pipeline #51124 failed with stage
in 3 minutes and 31 seconds
......@@ -108,6 +108,16 @@ def test_delayed_samples():
def load_annot():
return "annotation"
def load_annot_variant():
return "annotation_variant"
delayed_attr_read = False
def load_check():
nonlocal delayed_attr_read
delayed_attr_read = True
return "delayed_attr_data"
delayed_sample = DelayedSample(load_data, delayed_attributes=dict(annot=load_annot))
assert delayed_sample.data == 0, delayed_sample.data
assert delayed_sample.annot == "annotation", delayed_sample.annot
......@@ -120,5 +130,21 @@ def test_delayed_samples():
"annot": "annotation",
}, child_sample.__dict__
# Overwriting and adding delayed_attributes to the child
new_delayed_attr = {
"annot": load_annot_variant, # Override parent's annot
"new_annot": load_annot, # Add the new_annot attribute
"read_check": load_check,
}
child_sample = DelayedSample(
load_data, parent=delayed_sample, delayed_attributes=new_delayed_attr
)
assert child_sample.data == 0, child_sample.data
assert child_sample.annot == "annotation_variant", child_sample.annot
assert child_sample.new_annot == "annotation", child_sample.new_annot
assert delayed_attr_read == False, "delayed attribute has been read early"
assert child_sample.read_check == "delayed_attr_data", child_sample.read_check
assert delayed_attr_read == True
delayed_sample.annot = "changed"
assert delayed_sample.annot == "changed", delayed_sample.annot
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment