Beispiel #1
0
    def test_equality_condition(self):
        """testing if the equality condition works here to; it is
        inherited from the parent class 'Particle'
        """

        wall1 = base_classes.Wall(x=5000,
                                  y=0,
                                  inclination=0,
                                  is_fixed=True,
                                  length=10000)
        wall2 = base_classes.Wall(x=5000,
                                  y=0,
                                  inclination=0,
                                  is_fixed=True,
                                  length=10000)
        self.assertEqual(wall1, wall1)
        self.assertNotEqual(wall1, wall2)
Beispiel #2
0
    def test_ascending_particle_number(self):
        """testing if the particle number thing works in this class too
        in the ascending manner; it should be correctly inherited from
        the parent class 'Particle'
        """

        wall1 = base_classes.Wall(x=0,
                                  y=0,
                                  inclination=np.math.pi / 2,
                                  is_fixed=True,
                                  length=10000)
        wall2 = base_classes.Wall(x=5000,
                                  y=0,
                                  inclination=0,
                                  is_fixed=True,
                                  length=10000)
        self.assertEqual(wall1.num + 1, wall2.num)
Beispiel #3
0
    def test_shape(self):
        """testing if the 'shape' attribute is assigned correctly
        """

        wall = base_classes.Wall(x=5000,
                                 y=0,
                                 inclination=np.math.pi / 2,
                                 is_fixed=True,
                                 length=10000)
        end1 = shapes.Point(5000, -5000)
        end2 = shapes.Point(5000, 5000)
        exp = shapes.LineSegment(end1, end2)
        self.assertEqual(wall.shape, exp)
Beispiel #4
0
    def test_hashable(self):
        """testing if the particle being hashable works here too; it is
        inherited from the parent class 'Particle'
        """

        wall = base_classes.Wall(x=5000,
                                 y=0,
                                 inclination=0,
                                 is_fixed=True,
                                 length=10000)
        s = {wall}
        self.assertTrue(s)
        d = {wall: 1}
        self.assertEqual(d[wall], 1)
Beispiel #5
0
    def test_from_ends(self):
        """testing the classmethod 'from_ends'
        """

        x1, y1 = 0, 0
        x2, y2 = 0, 10000
        wall1 = base_classes.Wall(x=0,
                                  y=5000,
                                  inclination=np.math.pi / 2,
                                  is_fixed=True,
                                  length=10000)
        wall2 = base_classes.Wall.from_ends(x1, x2, y1, y2)
        exp = shapes.LineSegment(shapes.Point(x1, y1), shapes.Point(x2, y2))
        self.assertEqual(wall1.shape, wall2.shape)
        self.assertEqual(wall2.shape, exp)
Beispiel #6
0
    def test_attribute_assigning(self):
        """testing if all the attributes are assigned correctly; this
        includes those of the parent class 'Particle'
        """

        wall = base_classes.Wall(x=5000,
                                 y=0,
                                 inclination=np.math.pi / 2,
                                 is_fixed=True,
                                 length=10000)
        self.assertEqual(wall.x, 5000)
        self.assertEqual(wall.y, 0)
        self.assertAlmostEqual(wall.inclination, np.math.pi / 2)
        self.assertEqual(wall.length, 10000)
        self.assertEqual(wall.force, (0, 0, 0))
        self.assertEqual(wall.velocity, (0, 0, 0))
Beispiel #7
0
    def test_move(self):
        """testing if the Wall instance moves correctly with the given
        derivatives; this is inherited from the parent class 'Particle'
        """

        wall = base_classes.Wall(x=5000,
                                 y=0,
                                 inclination=0,
                                 is_fixed=True,
                                 length=10000)
        wall.move(delta_x=1000, delta_theta=np.math.pi)
        self.assertEqual(wall.x, 6000)
        self.assertEqual(wall.y, 0)
        self.assertEqual(wall.inclination, 0)
        self.assertEqual(
            wall.shape,
            shapes.LineSegment(shapes.Point(1000, 0), shapes.Point(11000, 0)))