MCPcopy Create free account
hub / github.com/NTNU-IHB/PythonFMU / test_zip_content

Function test_zip_content

pythonfmu/tests/test_builder.py:25–60  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

23
24
25def test_zip_content(tmp_path):
26
27 script_name = "pythonslave.py"
28 script_file = Path(__file__).parent / "slaves" / script_name
29 fmu = FmuBuilder.build_FMU(script_file, dest=tmp_path)
30 assert fmu.exists()
31 assert zipfile.is_zipfile(fmu)
32
33 with zipfile.ZipFile(fmu) as files:
34 names = files.namelist()
35
36 assert "modelDescription.xml" in names
37 assert "/".join(("resources", script_name)) in names
38 module_file = "/".join(("resources", "slavemodule.txt"))
39 assert module_file in names
40
41 nfiles = 16
42 if FmuBuilder.has_binary():
43 assert (
44 "/".join(("binaries", get_platform(), f"PythonSlave.{lib_extension}"))
45 in names
46 )
47 else:
48 nfiles -= 1
49
50 # Check pythonfmu is embedded
51 pkg_folder = Path(pythonfmu.__path__[0])
52 for f in pkg_folder.rglob("*.py"):
53 relative_f = f.relative_to(pkg_folder).as_posix()
54 if "test" not in relative_f:
55 assert "/".join(("resources", "pythonfmu", relative_f)) in names
56
57 assert len(names) >= nfiles # Library + python script + XML + module name + sources
58
59 with files.open(module_file) as myfile:
60 assert myfile.read() == b"pythonslave"
61
62
63@pytest.mark.parametrize("pfiles", PROJECT_TEST_CASES)

Callers

nothing calls this directly

Calls 3

get_platformFunction · 0.85
has_binaryMethod · 0.80
build_FMUMethod · 0.45

Tested by

no test coverage detected