def test_when_fill_descriptor_is_not_specified(runner, source, output, expected): source = data_filename_resolver(source) with runner.isolated_filesystem() as test_folder: result = runner.invoke(mckit, args=['compose', "--output", output, source], catch_exceptions=False) assert result.exit_code == 0, "Should success using fill_descriptor in the same directory as source file" assert Path(output).exists( ), f"Should create file {output} file in {test_folder}" # text = Path(output).read_text() # assert "simple" in text actual = mk.read_mcnp(output) expected = mk.read_mcnp(data_filename_resolver(expected)) assert actual.has_equivalent_cells(expected), "Cells differ" # TODO dvp: add tests for both anonimous and numbered form of universe transformation spectification
def test_when_only_source_is_specified(runner, source, expected): source: Path = data_filename_resolver(source) with runner.isolated_filesystem(): result = runner.invoke(mckit, args=['decompose', source], catch_exceptions=False) assert result.exit_code == 0, \ "Should success without specified output: " + result.output output: Path = get_default_output_directory(source) for f in expected: p = output / f assert p.exists(), \ f"Should store the file {p} in the default directory '{output}'" model = mk.read_mcnp(p) for cell in model: assert 'U' not in cell.options or cell.options['U'].name() == 0
def load_model(path: str) -> mk.Universe: # The cp1251-encoding reads C-model with various kryakozyabrs model: mk.Universe = mk.read_mcnp(path, encoding="Cp1251") return model
def model(): return read_mcnp('test/prepare/model1.i')
def read_mcnp_input(inp_filename): print('Reading MCNP model ({0}) ...'.format(inp_filename)) return read_mcnp(inp_filename)
def test_input_files_reading(path, expected_cells): universe = mk.read_mcnp(data_filename_resolver(path)) assert len(universe) == expected_cells, f"Failed to read from file {path}"
def load_universe(universe_name: int) -> mk.Universe: universe_path = get_path(universe_name) assert universe_path.exists() universe = mk.read_mcnp(universe_path) return universe