Skip to content

Commit

Permalink
Test number init.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Nov 22, 2024
1 parent e2a7079 commit 0009c78
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_cell_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def test_init(line, is_void, mat_number, density, atom_dens, parameters):
assert cell.parameters[parameter]["data"][0].value == pytest.approx(value)


def test_blank_num_init():
cell = Cell(number=5)
assert cell.number == 5


@pytest.mark.parametrize("line", ["foo", "foo bar", "1 foo", "1 1 foo"])
def test_malformed_init(line):
with pytest.raises(montepy.errors.MalformedInputError):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ def test_bad_init(line):
Material(input)


def test_mat_num_init():
mat = Material(number=5)
assert mat.number == 5


@pytest.mark.filterwarnings("ignore")
@given(st.integers(), st.integers())
def test_mat_clone(start_num, step):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def test_surface_init(self):
card = Input([in_str], BlockType.SURFACE)
with self.assertRaises(MalformedInputError):
Surface(card)
surf = Surface(number=5)
assert surf.number == 5

def test_validator(self):
surf = Surface()
Expand Down Expand Up @@ -234,6 +236,8 @@ def test_axis_plane_init(self):
surf = montepy.surfaces.axis_plane.AxisPlane(
Input([bad_input], BlockType.SURFACE)
)
surf = montepy.surfaces.axis_plane.AxisPlane(number=5)
assert surf.number == 5

def test_cylinder_on_axis_init(self):
bad_inputs = ["1 P 0.0", "1 CZ 0.0 10.0"]
Expand All @@ -242,6 +246,8 @@ def test_cylinder_on_axis_init(self):
surf = montepy.surfaces.cylinder_on_axis.CylinderOnAxis(
Input([bad_input], BlockType.SURFACE)
)
surf = montepy.surfaces.cylinder_on_axis.CylinderOnAxis(number=5)
assert surf.number == 5

def test_cylinder_par_axis_init(self):
bad_inputs = ["1 P 0.0", "1 C/Z 0.0"]
Expand All @@ -250,6 +256,8 @@ def test_cylinder_par_axis_init(self):
surf = montepy.surfaces.cylinder_par_axis.CylinderParAxis(
Input([bad_input], BlockType.SURFACE)
)
surf = montepy.surfaces.cylinder_par_axis.CylinderParAxis(number=5)
assert surf.number == 5

def test_gen_plane_init(self):
bad_inputs = ["1 PZ 0.0", "1 P 0.0"]
Expand All @@ -258,6 +266,8 @@ def test_gen_plane_init(self):
surf = montepy.surfaces.general_plane.GeneralPlane(
Input([bad_input], BlockType.SURFACE)
)
surf = montepy.surfaces.general_plane.GeneralPlane(number=5)
assert surf.number == 5

def test_axis_plane_location_setter(self):
in_str = "1 PZ 0.0"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def test_transform_init(self):
with self.assertRaises(MalformedInputError):
card = Input(["TR5:n,p 0.0 0.0 0.0"], BlockType.DATA)
Transform(card)
transform = Transform(number=5)
assert transform.number == 5

# test vanilla case
in_str = "tr5 " + "1.0 " * 3 + "0.0 " * 9
Expand Down

0 comments on commit 0009c78

Please sign in to comment.