def testValidateEllipse(self):
        e1 = Ellipse(0, 0, 2, 0, 0, 1, 3, 0, 0, 2)
        Validator.validateEllipse(e1, "Ellipse unexpectedly invalid")

        self.assertRaises(
            ShapeException, Validator.validateEllipse,
            "(0, 0, 2, 0, 1, 0, 3, 0, 0, 2)",
            "String \'(0, 0, 2, 0, 0, 1, 3, 0, 0, 2)\' is not a valid ellipse")
        self.assertRaises(ShapeException, Validator.validateEllipse,
                          Point(1, 1), "Point is not a valid ellipse")
Beispiel #2
0
 def __constructWithPoints(self, point1, point2, point3, point4, point5):
     try:
         self.__center = point1
         focus1 = point2
         focus2 = point3
         mirror1 = self.__getMirrorFocus(self.__center, focus1)
         mirror2 = self.__getMirrorFocus(self.__center, focus2)
         self.__foci1 = [focus1, mirror1]
         self.__foci2 = [focus2, mirror2]
         self.__axis1 = Line(self.__center.copy(), point4)
         self.__axis2 = Line(self.__center.copy(), point5)
         Validator.validateEllipse(value=self,
                                   errorMessage="Ellipse is invalid")
         return True
     except ShapeException:
         return False
Beispiel #3
0
 def __constructWithCoords(self, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5):
     try:
         self.__center = Point(x1, y1)
         focus1 = Point(x2, y2)
         focus2 = Point(x3, y3)
         mirror1 = self.__getMirrorFocus(self.__center, focus1)
         mirror2 = self.__getMirrorFocus(self.__center, focus2)
         self.__foci1 = [focus1, mirror1]
         self.__foci2 = [focus2, mirror2]
         self.__axis1 = Line(self.__center.copy(), Point(x4, y4))
         self.__axis2 = Line(self.__center.copy(), Point(x5, y5))
         Validator.validateEllipse(value=self,
                                   errorMessage="Ellipse is invalid")
         return True
     except ShapeException:
         return False