class TestShape(unittest.TestCase): def setUp(self): self.s1 = Shape(None, '', 1, (5, 5), (0, 0, 0)) self.s2 = Shape(None, '', 2, (60, 80), (255, 0, 255)) def testAdd(self): s3 = self.s1.add(self.s2) self.assertEqual(s3.scale, 3) self.assertEqual(s3.color, (0, 0, 0)) def testClone(self): s3 = self.s1.clone() s4 = self.s1 self.assertTrue(self.s1 == s4) self.assertFalse(self.s1 == s3) def testEquals(self): s3 = Shape(None, '', 1, (5, 5), (0, 0, 0)) self.assertTrue(self.s1.equals(s3))
def doOperation(self, shape1 : Shape, shape2: Shape) -> Shape: """ ------------------------------------------------------------------ doOperation: Compares ------------------------------------------------------------------ Parameters: shape1: first Shape to be compared shape2: Second Shape to be compared Returns: return newshape on top right corner of square if True else on the bottom right cornoer """ if(shape1.equals(shape2)): retTuple = (self.startPointx + self.width, self.startPointy - self.height/2) retShape = Shape(shape1.screen, shape1.filename, shape1.scale, retTuple, shape1.color) retShape.update() return retShape else: retTuple = (self.startPointx + self.width, self.startPointy + self.width/2) retShape = Shape(shape1.screen, shape1.filename, shape1.scale, retTuple, shape1.color) retShape.update() return retShape
def action(s1: Shape, s2: Shape): return [s1.greater(s2)]
# in_node_loc=(0, 0)) # # def testExe(self): # self.cm.reset() # self.cm.start() # self.cm.execute() # self.cm.execute() # self.assertEqual(self.out.execute()[0].scale, 6) # # def testAuto(self): # out = self.cm.auto() # self.assertEqual(out[0].scale, 6) if '__main__' == __name__: out = OutNode((0, 0), 1) a1 = AdditionNode(next_node=out, loc=(0, 0)) a2 = AdditionNode(next_node=a1, loc=(0, 0)) s1 = Shape(None, '', 1, (5, 5), (0, 0, 0)) s2 = Shape(None, '', 2, (5, 5), (0, 0, 0)) s3 = Shape(None, '', 3, (5, 5), (0, 0, 0)) s4 = Shape(None, '', 6, (5, 5), (0, 0, 0)) a = [a1, a2] ports = [(s1, a2), (s2, a2), (s3, a1)] p1 = [s1, s2, s3] p2 = [a2, a2, a1] in_node = InNode(ports, (0, 0), 3) ct = CommandTester(in_node, out, a) print(ct.test_auto(p1, [s4]))
def setUp(self): self.s1 = Shape(None, '', 1, (5, 5), (0, 0, 0)) self.s2 = Shape(None, '', 2, (60, 80), (255, 0, 255))
def testEquals(self): s3 = Shape(None, '', 1, (5, 5), (0, 0, 0)) self.assertTrue(self.s1.equals(s3))
def action(s1: Shape, s2: Shape): return [s1.add(s2)]
def action(s1: Shape, s2: Shape): return [s1.equals(s2)]