Coverage for skema/program_analysis/tests/test_code2fn.py: 100%
21 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-30 17:15 +0000
1import json
2import requests
3import zipfile
4import io
5from pathlib import Path
6from tempfile import TemporaryFile, TemporaryDirectory
8from skema.program_analysis.multi_file_ingester import process_file_system
9from skema.gromet.fn import GrometFNModuleCollection
10from skema.data.program_analysis import MODEL_ZIP_ROOT_PATH
12BUCKY_ZIP_URL = MODEL_ZIP_ROOT_PATH.resolve() / "Bucky.zip"
14def test_code2fn():
15 """This is simply a smokescreen test to see if the PA pipeline runs to
16 completion without crashing. It does not test the actual outputs.
18 This is because the output JSON contains randomly generated UUIDs, making
19 deterministic testing difficult. In the future, it would be good to add a
20 flag or postprocessing function to be able to compare two GroMEts modulo
21 their random components."""
23 zip = zipfile.ZipFile(io.BytesIO(BUCKY_ZIP_URL.read_bytes()))
25 with TemporaryDirectory() as temp:
26 system_filepaths_path = Path(temp) / "system_filepaths.txt"
27 system_filepaths_path.write_text("\n".join([file.filename for file in zip.filelist]))
29 for file in zip.filelist:
30 file_path = Path(temp) / file.filename
31 file_path.parent.mkdir(parents=True, exist_ok=True)
32 file_path.write_text(str(zip.open(file, "r").read(), encoding="utf-8"))
34 module_collection: GrometFNModuleCollection = process_file_system(
35 "chime_penn",
36 str(temp),
37 str(system_filepaths_path),
38 )
40 # If we've made it this far the Gromet pipeline has run without crashing
41 assert True