diff --git a/src/geouned/GEOUNED/Write/WriteFiles.py b/src/geouned/GEOUNED/Write/WriteFiles.py index 80bd75ca..64d45cd4 100644 --- a/src/geouned/GEOUNED/Write/WriteFiles.py +++ b/src/geouned/GEOUNED/Write/WriteFiles.py @@ -9,6 +9,15 @@ def writeGeometry(UniverseBox, MetaList, Surfaces, code_setting): baseName = code_setting["geometryName"] + # Currently there are two was of setting outFormat (via a .set method and + # a class attribute. Once we have a single method then move this validating + # input code to the attribute @setter + supported_mc_codes = ('mcnp', 'openMC_XML', 'openMC_PY', 'serpent', 'phits') + for out_format in code_setting['outFormat']: + if out_format not in supported_mc_codes: + msg = f'outFormat {out_format} not in supported MC codes ({supported_mc_codes})' + raise ValueError(msg) + # write cells comments in file if code_setting["cellCommentFile"]: OutFiles.commentsWrite(baseName, MetaList) diff --git a/tests/test_convert.py b/tests/test_convert.py index ce569b1d..d890a4b4 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -22,7 +22,7 @@ def test_conversion(input_step_file): "title" : 'Input Test' , "stepFile" : f"{input_step_file.resolve()}" , "geometryName" : f"{output_filename_stem.resolve()}" , - "outFormat" : ('mcnp', 'openMC_XML') , + "outFormat" : ('mcnp', 'openMC_XML', 'openMC_PY', 'serpent', 'phits'), "compSolids" : False , "volCARD" : False , "volSDEF" : True , @@ -39,9 +39,10 @@ def test_conversion(input_step_file): "nPlaneReverse" : 0 , } - # deletes the output openmc and mcnp output files if it already exists - output_filename_stem.with_suffix(".mcnp").unlink(missing_ok=True) - output_filename_stem.with_suffix(".xml").unlink(missing_ok=True) + # deletes the output MC files if they already exists + suffixes = ('.mcnp', '.xml', '.inp', '.py', '.serp') + for suffix in suffixes: + output_filename_stem.with_suffix(suffix).unlink(missing_ok=True) GEO = CadToCsg('Input Test') @@ -51,5 +52,5 @@ def test_conversion(input_step_file): GEO.Start() - assert output_filename_stem.with_suffix(".mcnp").exists() - assert output_filename_stem.with_suffix(".xml").exists() + for suffix in suffixes: + assert output_filename_stem.with_suffix(suffix).exists()