Пример #1
0
    def testInit(self):
        """
        testInit makes assertations about things
        that should happen when a MasterRobot
        is created.
        """
        mediator = RobotMediator()
        helper = HelperRobot(mediator)
        master = MasterRobot(mediator)

        # Is helper an instance of MasterRobot?
        self.assertIsInstance(master, MasterRobot)
        # Is helper also an instance of Robot?
        self.assertIsInstance(master, Robot)
        # Robot should not be working on a task yet.
        self.assertFalse(master.isRunning())
        # master should have been added to mediator's
        # list of robots.
        self.assertIn(master, mediator.getRobots())
        # helper should have been added to mediator's
        # list of robots too.
        self.assertIn(helper, mediator.getRobots())
        # Master can also be alone without any helpers.
        masterAlone = MasterRobot()
        self.assertNotIn(masterAlone,
            mediator.getRobots())
Пример #2
0
    def testInit(self):
        """
        testInit makes assertations about things
        that should happen when a HelperRobot
        is created.
        """
        mediator = RobotMediator()
        helper = HelperRobot(mediator)

        # Is helper an instance of HelperRobot?
        self.assertIsInstance(helper, HelperRobot)
        # Is helper also an instance of Robot?
        self.assertIsInstance(helper, Robot)
        # Robot should not be working on a task yet.
        self.assertFalse(helper.isRunning())
        # helper should have been added to mediator's
        # list of robots.
        self.assertIn(helper, mediator.getRobots())
    def testInit(self):
        """
        Test the initialization of a robotMediator.
        """
        # Create a mediator object
        try:
            mediator = RobotMediator()
        except Exception as e:
            self.fail(e)
        # mediator should be an instance of
        # the RobotMediator class.
        self.assertIsInstance(mediator, RobotMediator)
        # It should also be an instance of the 
        # Mediator interface.
        self.assertIsInstance(mediator, Mediator)

        # RobotMediator should have an empty list.
        self.assertEquals([], mediator.getRobots())