Skip to content

Commit

Permalink
Add todo and def lines to test_imports.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aclum authored Oct 1, 2024
1 parent 612e02e commit 07fcc96
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,59 @@


@fixture

#TODO NOW: update to use real import.yaml file
#TODO NEXT: add test for import-mt.yaml similar to what is in test_workflow_process.py
def gold_mapper(mock_api, base_test_dir, test_data_dir):
"""
Base test function for code related to importing JGI records.
"""
yaml_file = base_test_dir / "import_test.yaml"
test_files = [test_data_dir / "test_pfam.gff",
test_data_dir / "test_cog.gff",
test_data_dir / "test_2.tar.gz",
test_data_dir / "test_72.tar.gz"]
# proj_dir = os.path.abspath("./test_data")
site_conf = base_test_dir / "site_configuration_test.toml"
omics_id = "nmdc:omprc-11-importT"
nucleotide_sequencing_id = "nmdc:omprc-11-importT"
root_dir = f"/tmp/{omics_id}"
if os.path.exists(root_dir):
shutil.rmtree(root_dir)
gm = GoldMapper("1", test_files, omics_id, yaml_file, test_data_dir, site_conf)
gm = GoldMapper("1", test_files, nucleotide_sequencing_id, yaml_file, test_data_dir, site_conf)
gm.root_dir = root_dir
return gm


def test_activity_mapper(gold_mapper):
"""
Test the creation of workflow execution records and data objects that are has_output of those workflow execution subclasses.
"""
gold_mapper.unique_object_mapper()
gold_mapper.multiple_objects_mapper()
gold_mapper.activity_mapper()
gold_mapper.post_nmdc_database_object()
db = gold_mapper.get_database_object_dump()
#TODO I think this assert statement should be 2 ANC
assert len(db.workflow_execution_set) == 4
#This should return 2 workflow_execution_set records, one nmdc:MetagenomeAnnotation and one nmdc:MagsAnalysis.
assert len(db.workflow_execution_set) == 2
# gff files are 1:1 with data objects that are has_output of nmdc:MetagenomeAnnotation
# *tar.gz files should be combined into a single data object that is has_output of nmdc:MagsAnalysis
assert len(db.data_object_set) == 3


def test_unique_object_mapper(gold_mapper):
"""
This test counts the number of files from gold_mapper where the data object creation should be 1:1.
"""
gold_mapper.unique_object_mapper()
assert len(gold_mapper.nmdc_db.data_object_set) == 2
assert len(gold_mapper.objects) == 2


def test_multiple_object_mapper(gold_mapper):
"""
This test counts the number of files from gold_mapper where the data object creation should be many:1. JGI stores each binning file
individually whereas NMDC combines all the records into a single tar.gz file.
"""
gold_mapper.multiple_objects_mapper()
# Add assertions to check if the method works as expected
assert len(gold_mapper.nmdc_db.data_object_set) == 1
Expand Down

0 comments on commit 07fcc96

Please sign in to comment.