Esempio n. 1
0
 def testUnassignedItems(self):
     r1 = RobotBrain()
     r1.updateBoxes([(1, 1)], [])
     r1.updateHoles([(2, 2)])
     r1.updateCachedChanges()
     self.assertEqual(r1.getUnassignedBoxes(), [(1, 1)])
     self.assertEqual(r1.getUnassignedHoles(), [(2, 2)])
Esempio n. 2
0
    def testUpdateBrain(self):
        r1 = RobotBrain()
        r2 = RobotBrain()
        boxes, holes = [(1, 1)], sorted([(2, 1), (2, 3)])
        r1.updateBoxes(boxes, [])
        r1.updateHoles(holes)
        r1.updateCachedChanges()
        r2.updateAssignments(r1)
        self.assertEqual(r2.boxes.keys(), boxes)
        self.assertEqual(sorted(r2.holes.keys()), holes)

        r1.assignBox(boxes[0], 'bob')
        self.assertEqual(r2.isBoxAssigned(boxes[0]), False)
        r2.updateAssignments(r1)
        self.assertEqual(r2.isBoxAssigned(boxes[0]), True)
Esempio n. 3
0
 def testUpdateBoxesHoles(self):
     b = RobotBrain()
     b.updateBoxes([(0, 0), (1, 0)], [])
     b.updateCachedChanges()
     self.assertEqual(b.boxes, {(0, 0): None, (1, 0): None})