Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andped10 committed Jan 22, 2024
1 parent f89a260 commit 65c31a2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/sample/items/test_gradient_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ def test_init(self):
result = GradientLayer(
initial_material=init,
final_material=final,
thickness=Parameter('thickness', 1.0),
roughness=Parameter('roughness', 2.0),
thickness=1.0,
roughness=2.0,
discretisation_elements=10,
name='Test',
conformal_roughness=False,
interface=None
)

Expand All @@ -33,10 +32,11 @@ def test_init(self):
assert result.name, 'Test'
assert result.type, 'Gradient-layer'
assert result.interface is None
assert len(result.layers) == 10
assert result.thickness == 1.0
assert result.layers.name == '0/1/2/3/4/5/6/7/8/9'
assert result.layers[0].material.sld.raw_value == 10.0
assert result.layers[5].material.sld.raw_value == 5.0
assert result.layers[0].thickness.raw_value == 0.1
assert result.layers[5].material.isld.raw_value == -5.0
assert result.layers[9].material.isld.raw_value == -1.0

Expand All @@ -48,8 +48,8 @@ def test_default(self):
assert result.name == 'Air-Deuterium'
assert result.type, 'Gradient-layer'
assert result.interface is None
assert len(result.layers) == 20
assert result.layers.name == '0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19'
assert len(result.layers) == 10
assert result.layers.name == '0/1/2/3/4/5/6/7/8/9'

def test_from_pars(self):
# When
Expand All @@ -62,7 +62,7 @@ def test_from_pars(self):
final_material=final,
thickness=10.0,
roughness=1.0,
discretisation_thickness=2.0,
discretisation_elements=5,
name='gradientItem'
)

Expand Down Expand Up @@ -102,7 +102,7 @@ def test_repr(self):
result = GradientLayer.default()

# Expect
expected_str = "type: Gradient-layer\nthickness: 2\ndiscretisation_thickness: 0.1\ninitial_layer:\n '0':\n material:\n EasyMaterial:\n sld: 0.000e-6 1 / angstrom ** 2\n isld: 0.000e-6 1 / angstrom ** 2\n thickness: 0.100 angstrom\n roughness: 0.000 angstrom\nfinal_layer:\n '19':\n material:\n EasyMaterial:\n sld: 6.042e-6 1 / angstrom ** 2\n isld: 0.000e-6 1 / angstrom ** 2\n thickness: 0.100 angstrom\n roughness: 0.000 angstrom\n"
expected_str = "type: Gradient-layer\nthickness: 2.0\ndiscretisation_elements: 10\ninitial_layer:\n '0':\n material:\n EasyMaterial:\n sld: 0.000e-6 1 / angstrom ** 2\n isld: 0.000e-6 1 / angstrom ** 2\n thickness: 0.200 angstrom\n roughness: 0.000 angstrom\nfinal_layer:\n '9':\n material:\n EasyMaterial:\n sld: 5.724e-6 1 / angstrom ** 2\n isld: 0.000e-6 1 / angstrom ** 2\n thickness: 0.200 angstrom\n roughness: 0.000 angstrom\n"
assert result.__repr__() == expected_str

def test_dict_round_trip(self):
Expand All @@ -116,7 +116,7 @@ def test_dict_round_trip(self):
assert result.as_data_dict() == default.as_data_dict()
assert len(default.layers) == len(result.layers)
# Just one layer of the generated layers is checked
assert default.layers[10].__repr__() == result.layers[10].__repr__()
assert default.layers[5].__repr__() == result.layers[5].__repr__()


def test_linear_gradient_increasing():
Expand Down

0 comments on commit 65c31a2

Please sign in to comment.