コード例 #1
0
    def test_absolute_shape_volume(self):
        """creates a rotated shape using straight and spline connections and \
                checks the volume is correct"""

        test_shape = RotateMixedShape(
            points=[(0, 0,
                     "straight"), (0, 20,
                                   "spline"), (20, 20,
                                               "spline"), (20, 0, "spline")])

        test_shape.rotation_angle = 360
        test_shape.create_solid()

        assert test_shape.solid is not None
        assert test_shape.volume > 100

        test_shape2 = RotateMixedShape(
            points=[(0, 0,
                     "straight"), (0, 20,
                                   "spline"), (20, 20,
                                               "spline"), (20, 0, "spline")])

        test_shape2.rotation_angle = 180
        test_shape2.create_solid()

        assert test_shape2.solid is not None
        assert 2 * test_shape2.volume == test_shape.volume
コード例 #2
0
        def incorrect_number_of_connections_function():
            """checks ValueError is raised when an incorrect number of
            connections is specified"""

            test_shape = RotateMixedShape(
                points=[(0, 200, "straight"), (200, 100), (0, 0, "spline"), ]
            )

            test_shape.create_solid()
コード例 #3
0
        def incorrect_number_of_connections_function():
            """checks that a ValueError is raised when an incorrect \
                           number of connections are specified. There are 3 \
                           points set, so only 4 connections are needed"""
            test_shape = RotateMixedShape(points=[
                (0, 200, "straight"),
                (200, 100),
                (0, 0, "spline"),
            ])

            test_shape.create_solid()
コード例 #4
0
    def test_shape_volume_with_multiple_azimuth_placement_angles(self):
        """creates rotated shapes at multiple placement angles using mixed connections
        and checks the volumes are correct"""

        test_shape = RotateMixedShape(
            points=[
                (1, 1, "straight"),
                (1, 20, "spline"),
                (20, 20, "spline"),
                (20, 1, "spline"),
            ]
        )

        test_shape.rotation_angle = 10
        test_shape.azimuth_placement_angle = [0, 90, 180, 270]
        test_shape.create_solid()

        assert test_shape.solid is not None
        assert test_shape.volume > 100

        test_shape2 = RotateMixedShape(
            points=[
                (1, 1, "straight"),
                (1, 20, "spline"),
                (20, 20, "spline"),
                (20, 1, "spline"),
            ]
        )

        test_shape2.rotation_angle = 5
        test_shape2.azimuth_placement_angle = [0, 90, 180, 270]
        test_shape2.create_solid()

        assert test_shape2.solid is not None
        assert 2 * test_shape2.volume == pytest.approx(test_shape.volume)

        test_shape3 = RotateMixedShape(
            points=[
                (1, 1, "straight"),
                (1, 20, "spline"),
                (20, 20, "spline"),
                (20, 1, "spline"),
            ]
        )

        test_shape3.rotation_angle = 20
        test_shape3.azimuth_placement_angle = [0, 180]
        test_shape3.create_solid()

        assert test_shape3.solid is not None
        assert test_shape3.volume == pytest.approx(test_shape.volume)