Skip to content

Commit

Permalink
Update fixtures to replicate error
Browse files Browse the repository at this point in the history
        for wf in workflows:
            required_types.update(set(wf.data_object_types))

        required_data_objs_by_id = dict()
        for rec in db.data_object_set.find():
            do = DataObject(**rec)
>           if do.data_object_type.code.text not in required_types:
E           AttributeError: 'NoneType' object has no attribute 'code'
  • Loading branch information
mbthornton-lbl committed Nov 20, 2024
1 parent 21240c7 commit cbec96c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tests/fixtures/nmdc_db/data_object_set.json
Original file line number Diff line number Diff line change
Expand Up @@ -815,5 +815,15 @@
"data_object_type": "Metatranscriptome Expression Info File",
"url": "https://data.microbiomedata.org",
"type": "nmdc:DataObject"
}
},
{
"id" : "nmdc:dobj-13-zzzyae97",
"name" : "output: SBR_FC_N1_00-10_H2Oext_13Oct15_Leopard_1_01_4404",
"description" : "High resolution MS spectra only",
"file_size_bytes" : 30539306,
"type" : "nmdc:DataObject",
"alternative_identifiers" : [
"emsl:output_456424"
]
}
]
9 changes: 7 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def test_data_object_creation_from_records(fixtures_dir):
assert data_obj.type == "nmdc:DataObject"
assert data_obj.id == record["id"]
assert data_obj.name == record["name"]
assert str(data_obj.data_object_type) == record["data_object_type"]
# not all data objects have a data_object_type - e.g. Mass Spectrometry data
if "data_object_type" in record:
assert str(data_obj.data_object_type) == record["data_object_type"]

data_obj_dict = yaml.safe_load(yaml_dumper.dumps(data_obj))
assert data_obj_dict == record
Expand All @@ -136,9 +138,12 @@ def test_data_object_creation_from_db_records(test_db, fixtures_dir):
assert data_obj.type == "nmdc:DataObject"
assert data_obj.id == db_record["id"]
assert data_obj.name == db_record["name"]
# not all data objects have a data_object_type or url - e.g. Mass Spectrometry data
if not db_record.get("data_object_type"):
continue
assert str(data_obj.data_object_type) == db_record["data_object_type"]
assert data_obj.description == db_record["description"]
assert data_obj.url == db_record["url"]
assert data_obj.description == db_record["description"]
assert data_obj.file_size_bytes == db_record.get("file_size_bytes")
assert data_obj.md5_checksum == db_record["md5_checksum"]

Expand Down

0 comments on commit cbec96c

Please sign in to comment.