Skip to content

test_shieldhit_config_mappings

converter.tests.shieldhit.test_shieldhit_config_mappings

test_default_beam_config_str

test_default_beam_config_str()

Test if the default BeamConfig str representation is correct.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
74
75
76
def test_default_beam_config_str() -> None:
    """Test if the default BeamConfig str representation is correct."""
    assert str(BeamConfig()) == _Beam_template_default

test_default_detect_config_str

test_default_detect_config_str()

Test if the default MatConfig str representation is correct.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
84
85
86
def test_default_detect_config_str() -> None:
    """Test if the default MatConfig str representation is correct."""
    assert str(DetectConfig()) == _Detect_template_default

test_default_geo_config_str

test_default_geo_config_str()

Test if the default MatConfig str representation is correct.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
89
90
91
def test_default_geo_config_str() -> None:
    """Test if the default MatConfig str representation is correct."""
    assert GeoMatConfig().get_geo_string() == _Geo_template_default

test_default_mat_config_str

test_default_mat_config_str()

Test if the default MatConfig str representation is correct.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
79
80
81
def test_default_mat_config_str() -> None:
    """Test if the default MatConfig str representation is correct."""
    assert GeoMatConfig().get_mat_string() == _Mat_template_default

test_energy_cutoff

test_energy_cutoff()

Test if the energy cutoffs are correctly set.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def test_energy_cutoff() -> None:
    """Test if the energy cutoffs are correctly set."""
    beam = BeamConfig()
    beam.energy_low_cutoff = 0.0
    beam.energy_high_cutoff = 10.0
    assert "TCUT0       0.0 10.0  ! energy cutoffs [MeV]" in str(beam)

    beam.energy_low_cutoff = None
    assert "TCUT0" not in str(beam)

    beam.energy_high_cutoff = None
    assert "TCUT0" not in str(beam)

test_sad_parameter

test_sad_parameter(sad_x, sad_y)

Test if the BEAMSAD values are correctly set.

Source code in yaptide/converter/tests/shieldhit/test_shieldhit_config_mappings.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@pytest.mark.parametrize('sad_x, sad_y', [
    (None, None),
    (200, None),
    (210, 250),
])
def test_sad_parameter(sad_x: Optional[float], sad_y: Optional[float]) -> None:
    """Test if the BEAMSAD values are correctly set."""
    beam = BeamConfig()
    beam.sad_x = sad_x
    beam.sad_y = sad_y
    if sad_x is None and sad_y is None:
        assert "! no BEAMSAD value" in str(beam)
    elif sad_x is not None and sad_y is None:
        assert f"BEAMSAD {sad_x}   ! BEAMSAD value [cm]" in str(beam)
    elif sad_x is not None and sad_y is not None:
        assert f"BEAMSAD {sad_x} {sad_y}  ! BEAMSAD value [cm]" in str(beam)