def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveLeft = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = HasReadLetterBoardState(self.aGame)
Пример #2
0
class NearResistanceStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveLeft = mock.Mock(return_value="")
        Robot.moveRight = mock.Mock(return_value="")
        Robot.moveBackward = mock.Mock(return_value="")
        Robot.moveForward = mock.Mock(return_value="")
        Robot.refreshPositionAndAngle = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        NearResistanceState.requestObstaclesPositions = mock.Mock(
            return_value="")
        Robot.readResistance = mock.Mock(return_value=2000)
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = NearResistanceState(self.aGame)

    def test_whenGameDoAnActionInNearResistanceStateGameStateShouldChangeAtTheEnd(
            self):
        self.aGame.doAction()
        self.assertFalse(
            self.aGame.getCurrentStateName() == "HasReadResistanceState")

    def test_whenGameDoAnActionInNearResistanceStateResistanceValueShouldChange(
            self):
        self.aGame.doAction()
        self.assertFalse(self.aGame.getResistanceValue == -1)
Пример #3
0
class NearPucksStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveBackward = mock.Mock(return_value="")
        Robot.grabPuck = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        Robot.rotateClockwise = mock.Mock(return_value="")
        Robot.rotateCounterClockwise = mock.Mock(return_value="")
        Robot.moveBackward = mock.Mock(return_value="")
        Robot.moveForward = mock.Mock(return_value="")
        Robot.setCamMiddle = mock.Mock(return_value="")
        Robot.setCamDown = mock.Mock(return_value="")
        Robot.getDistanceToPuck = mock.Mock(return_value=(20, 15))
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.puckNumberBeingProcessed = 0
        self.aGame.listOfPucks = [
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE)
        ]
        self.aGame.currentState = NearPucksState(self.aGame)

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        print self.aGame.getCurrentStateName()
        self.assertTrue(self.aGame.getCurrentStateName() == "HasPuckState")
Пример #4
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.findOrientationInOrientationBoard = mock.Mock(return_value="SA")
     NearResistanceState.fetchResistance = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = NearOrientationBoardState(self.aGame)
     self.aGame.setPositionToReadInOrientationBoard(2)
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveRight = mock.Mock(return_value="")
     Robot.moveBackward = mock.Mock(return_value="")
     Robot.refreshPositionAndAngle = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveToPosition = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = HasReadResistanceState(self.aGame)
     self.aGame.setResistanceValue(25000)
     HasReadResistanceState.splitResistanceValueInThreeNumbers = mock.Mock(
         return_value=(2, 5, 3))
Пример #7
0
class HasPuckStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveToPosition = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = HasPuckState(self.aGame)

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(
            self.aGame.getCurrentStateName() == "NearGoalPositionState")
Пример #8
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveToPosition = mock.Mock(return_value="")
     Robot.setLedOn = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = HasNoPuckState(self.aGame)
     self.aGame.listOfPucks = [
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE)
     ]
Пример #9
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     Robot.findLetterInLetterBoard = mock.Mock(return_value="D")
     Robot.setCamMiddle = mock.Mock(return_value="")
     Robot.setCamUp = mock.Mock(return_value="")
     NearResistanceState.fetchResistance = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = NearLetterBoardState(self.aGame)
     self.aGame.listOfPucks = [Puck(RANDOM_COLOR_CODE), Puck(RANDOM_COLOR_CODE), Puck(RANDOM_COLOR_CODE)]
     self.aGame.setPositionToReadInLetterBoard(2)
class NoResistanceValueStateTest(unittest.TestCase):

    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveRight = mock.Mock(return_value="")
        Robot.moveBackward = mock.Mock(return_value="")
        Robot.refreshPositionAndAngle = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())

    def test_whenGameDoAnActionInNoResistanceValueStateGameStateShouldChangeStateAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "NearResistanceState")
Пример #11
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveLeft = mock.Mock(return_value="")
     Robot.moveRight = mock.Mock(return_value="")
     Robot.moveBackward = mock.Mock(return_value="")
     Robot.moveForward = mock.Mock(return_value="")
     Robot.refreshPositionAndAngle = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     NearResistanceState.requestObstaclesPositions = mock.Mock(
         return_value="")
     Robot.readResistance = mock.Mock(return_value=2000)
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = NearResistanceState(self.aGame)
Пример #12
0
def main():
    queue = Queue.Queue()
    robot = Robot(queue)
    game = Game(robot, queue)
    client = ThreadedClientRobot(queue, game)

    robotConnectionThread = threading.Thread(target=client.run)
    robotConnectionThread.daemon = True
    robotConnectionThread.start()

    #Main running the actions of the game
    while True:
        if game.isInProcess():
            game.doAction()
        elif game.isKilled == True:
            sys.exit(0)
Пример #13
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveLeft = mock.Mock(return_value="")
     Robot.moveRight = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = HasReadOrientationBoardState(self.aGame)
     puck1 = Puck(RANDOM_COLOR_CODE)
     puck1.setPriority(1)
     puck2 = Puck(RANDOM_COLOR_CODE)
     puck2.setPriority(2)
     puck3 = Puck(RANDOM_COLOR_CODE)
     puck3.setPriority(1)
     self.aGame.listOfPucks = [puck1, puck2, puck3]
     self.aGame.setPucksOrientation("SA")
     self.aGame.listOfPucks[0].setCornerToBePlaced("D")
     self.aGame.setPositionToReadInOrientationBoard(3)
Пример #14
0
class GameTest(unittest.TestCase):
    
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.game = Game(self.robot, Queue.Queue())
        
    def test_aGameWhenCreatedMustHaveZeroPuckInItsList(self):
        self.assertTrue(len(self.game.listOfPucks) == 0)
        
    def test_aGameWhenCreatedMustNotBeFinished(self):
        self.assertFalse(self.game.isFinished())
        
    def test_aGameWhenCreatedMustNotHaveAPuckBeingProcessed(self):
        self.assertTrue(self.game.getPuckNumberBeingProcessed() == 0)
        
    def test_aGameWhenCreatedMustNotHaveAResistanceValue(self):
        self.assertTrue(self.game.getResistanceValue() == -1)
        
    def test_aGameWhenCreatedMustNotHaveAPucksOrientation(self):
        self.assertTrue(self.game.getPucksOrientation() == "")
        
    def test_aGameWhenCreatedMustNotHaveAPositionToReadInitialisedForLetterBoard(self):
        self.assertTrue(self.game.getPositionToReadInLetterBoard() == -1)
        
    def test_aGameWhenCreatedMustNotHaveAPositionToReadInitialisedForOrientationBoard(self):
        self.assertTrue(self.game.getPositionToReadInOrientationBoard() == -1)
        
    def test_aGameWhenThreePucksPlacedShouldBeFinished(self):
        puck1 = Puck(RANDOM_COLOR_CODE)
        puck1.setHasBeenPlaced(True)
        puck2 = Puck(RANDOM_COLOR_CODE_1)
        puck2.setHasBeenPlaced(True)
        puck3 = Puck(RANDOM_COLOR_CODE_2)
        puck3.setHasBeenPlaced(True)
        self.game.listOfPucks.append(puck1)
        self.game.listOfPucks.append(puck2)
        self.game.listOfPucks.append(puck3)
        self.assertTrue(self.game.isFinished())
        
    def test_aGameWhenNotThreePucksPlacedShouldNotBeFinished(self):
        puck1 = Puck(RANDOM_COLOR_CODE)
        puck1.setHasBeenPlaced(True)
        puck2 = Puck(RANDOM_COLOR_CODE_1)
        puck2.setHasBeenPlaced(False)
        puck3 = Puck(RANDOM_COLOR_CODE_2)
        puck3.setHasBeenPlaced(True)
        self.game.listOfPucks.append(puck1)
        self.game.listOfPucks.append(puck2)
        self.game.listOfPucks.append(puck3)
        self.assertFalse(self.game.isFinished())
Пример #15
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveBackward = mock.Mock(return_value="")
     Robot.grabPuck = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     Robot.rotateClockwise = mock.Mock(return_value="")
     Robot.rotateCounterClockwise = mock.Mock(return_value="")
     Robot.moveBackward = mock.Mock(return_value="")
     Robot.moveForward = mock.Mock(return_value="")
     Robot.setCamMiddle = mock.Mock(return_value="")
     Robot.setCamDown = mock.Mock(return_value="")
     Robot.getDistanceToPuck = mock.Mock(return_value=(20, 15))
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.puckNumberBeingProcessed = 0
     self.aGame.listOfPucks = [
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE)
     ]
     self.aGame.currentState = NearPucksState(self.aGame)
Пример #16
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveToPosition = mock.Mock(return_value="")
     Robot.moveToRight = mock.Mock(return_value="")
     Robot.moveForward = mock.Mock(return_value="")
     Robot.rotateToAngle = mock.Mock(return_value="")
     NearGoalPositionState.goToCorner = mock.Mock(return_value="")
     Robot.findLetterInLetterBoard = mock.Mock(return_value="D")
     Robot.dropPuck = mock.Mock(return_value="SA")
     NearPucksState.fetchPuck = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = NearGoalPositionState(self.aGame)
     self.aGame.listOfPucks = [
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE),
         Puck(RANDOM_COLOR_CODE)
     ]
     self.aGame.setPucksOrientation("SA")
     self.aGame.setPositionToReadInLetterBoard(2)
     self.aGame.listOfPucks[0].setCornerToBePlaced("D")
Пример #17
0
class HasNoPuckStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveToPosition = mock.Mock(return_value="")
        Robot.setLedOn = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = HasNoPuckState(self.aGame)
        self.aGame.listOfPucks = [
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE)
        ]

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEndIfTheGameIsNotFinished(
            self):
        self.aGame.listOfPucks[0].setHasBeenPlaced(True)
        self.aGame.listOfPucks[1].setHasBeenPlaced(True)
        self.aGame.listOfPucks[2].setHasBeenPlaced(True)
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "HasNoPuckState")

    def test_whenGameDoAnActionStateGameStateShouldNotChangeAtTheEndIfTheGameIsFinished(
            self):
        self.aGame.listOfPucks[0].setHasBeenPlaced(True)
        self.aGame.listOfPucks[1].setHasBeenPlaced(True)
        self.aGame.listOfPucks[2].setHasBeenPlaced(False)
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "NearPucksState")
Пример #18
0
class NearOrientationBoardStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.findOrientationInOrientationBoard = mock.Mock(return_value="SA")
        NearResistanceState.fetchResistance = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = NearOrientationBoardState(self.aGame)
        self.aGame.setPositionToReadInOrientationBoard(2)

    def test_whenGameDoAnActionStatePuckOrientationShouldChange(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getPucksOrientation() == "SA")

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(
            self.aGame.getCurrentStateName() == "HasReadOrientationBoardState")
Пример #19
0
class NearLetterBoardStateTest(unittest.TestCase):

    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        Robot.findLetterInLetterBoard = mock.Mock(return_value="D")
        Robot.setCamMiddle = mock.Mock(return_value="")
        Robot.setCamUp = mock.Mock(return_value="")
        NearResistanceState.fetchResistance = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = NearLetterBoardState(self.aGame)
        self.aGame.listOfPucks = [Puck(RANDOM_COLOR_CODE), Puck(RANDOM_COLOR_CODE), Puck(RANDOM_COLOR_CODE)]
        self.aGame.setPositionToReadInLetterBoard(2)

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "HasReadLetterBoardState")
        
    def test_whenGameDoAnActionFirstPuckCornerShouldBeInitialized(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[0].getCornerToBePlaced() == "D")     
        
Пример #20
0
class HasReadOrientationBoardStateTest(unittest.TestCase):

    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveLeft = mock.Mock(return_value="")
        Robot.moveRight = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = HasReadOrientationBoardState(self.aGame)
        puck1 = Puck(RANDOM_COLOR_CODE)
        puck1.setPriority(1)
        puck2 = Puck(RANDOM_COLOR_CODE)
        puck2.setPriority(2)
        puck3 = Puck(RANDOM_COLOR_CODE)
        puck3.setPriority(1)
        self.aGame.listOfPucks = [puck1, puck2, puck3]
        self.aGame.setPucksOrientation("SA")
        self.aGame.listOfPucks[0].setCornerToBePlaced("D")
        self.aGame.setPositionToReadInOrientationBoard(3)

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "NearPucksState")
        
    def test_puckListShouldBeResetAccordingToPriority(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[0].getPriority() == 1)
        
    def test_whenGameDoAnActionPuckOneCornerShouldBeDWithSAOrientationAndDFirstCorner(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[0].getCornerToBePlaced() == "D")
        
    def test_whenGameDoAnActionPuckTwoCornerShouldBeDWithSAOrientationAndDFirstCornerWithPrioritySetted(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[1].getCornerToBePlaced() == "B")
        
    def test_whenGameDoAnActionPuckThreeCornerShouldBeDWithSAOrientationAndDFirstCornerWithPrioritySetted(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[2].getCornerToBePlaced() == "C")

        
    def test_whenGameDoAnActionNoPuckShouldHavePriorityToMinusOne(self):
        self.aGame.doAction()
        allPuckHaveAPriority = True
        for puck in self.aGame.listOfPucks:
            if puck.getPriority() == -1:
                allPuckHaveAPriority = False
        self.assertTrue(allPuckHaveAPriority)
        
    def test_whenGameDoAnActionNoPuckShouldHaveCornerToNothing(self):
        self.aGame.doAction()
        allPuckHaveACorner = True
        for puck in self.aGame.listOfPucks:
            if puck.getCornerToBePlaced == "":
                allPuckHaveACorner = False
        self.assertTrue(allPuckHaveACorner)
Пример #21
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     Robot.moveToPosition = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.aGame = Game(self.robot, Queue.Queue())
     self.aGame.currentState = HasPuckState(self.aGame)
class HasReadResistanceStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveToPosition = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = HasReadResistanceState(self.aGame)
        self.aGame.setResistanceValue(25000)
        HasReadResistanceState.splitResistanceValueInThreeNumbers = mock.Mock(
            return_value=(2, 5, 3))

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(
            self.aGame.getCurrentStateName() == "NearLetterBoardState")

    def test_whenGameDoAnActionPositionToReadInLetterBoardShouldChange(self):
        self.aGame.doAction()
        self.assertFalse(self.aGame.getPositionToReadInLetterBoard() == -1)

    def test_whenGameDoAnActionPositionToReadInOrientationBoardShouldChange(
            self):
        self.aGame.doAction()
        self.assertFalse(
            self.aGame.getPositionToReadInOrientationBoard() == -1)

    def test_whenGameDoAnActionListOfPucksShouldHaveThreePucks(self):
        self.aGame.doAction()
        self.assertTrue(len(self.aGame.listOfPucks) == 3)

    def test_whenGameDoAnActionPuckInListShouldNotBePlaced(self):
        self.aGame.doAction()
        self.assertFalse(self.aGame.listOfPucks[0].hasBeenPlaced)

    def test_whenGameDoAnActionPucksInListShouldNotHavePriorityToMinusOne(
            self):
        self.aGame.doAction()
        aPuckWithPriorityToMinusOneExist = False
        for puck in self.aGame.listOfPucks:
            if puck.getPriority() == -1:
                aPuckWithPriorityToMinusOneExist = True
        self.assertFalse(aPuckWithPriorityToMinusOneExist)

    def test_whenGameDoAnActionPuckInListShouldHaveCornerToBePlacedToNothing(
            self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.listOfPucks[0].getCornerToBePlaced() == "")

    def test_whenGameDoAnActionWithResistanceValue25000PucksColorShouldBeRedGreenOrange(
            self):
        self.aGame.doAction()
        gameHasARedPuck = False
        gameHasAGreenPuck = False
        gameHasAOrangePuck = False
        for puck in self.aGame.listOfPucks:
            if puck.getPrimaryColor() == RED_COLOR_CODE:
                gameHasARedPuck = True
            if puck.getPrimaryColor() == ORANGE_COLOR_CODE:
                gameHasAGreenPuck = True
            if puck.getPrimaryColor() == GREEN_COLOR_CODE:
                gameHasAOrangePuck = True
        self.assertTrue(gameHasARedPuck)
        self.assertTrue(gameHasAGreenPuck)
        self.assertTrue(gameHasAOrangePuck)

    def test_whenGameDoAnActionWithResistanceValue25000PositionToReadInLetterBoardShouldBeTwo(
            self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getPositionToReadInLetterBoard() == 2)

    def test_whenGameDoAnActionWithResistanceValue25000PositionToReadInOrientationBoardShouldBeFive(
            self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getPositionToReadInOrientationBoard() == 3)
Пример #23
0
class NearGoalPositionStateTest(unittest.TestCase):
    def setUp(self):
        Robot.initHardwareDevices = mock.Mock(return_value="")
        Robot.moveToPosition = mock.Mock(return_value="")
        Robot.moveToRight = mock.Mock(return_value="")
        Robot.moveForward = mock.Mock(return_value="")
        Robot.rotateToAngle = mock.Mock(return_value="")
        NearGoalPositionState.goToCorner = mock.Mock(return_value="")
        Robot.findLetterInLetterBoard = mock.Mock(return_value="D")
        Robot.dropPuck = mock.Mock(return_value="SA")
        NearPucksState.fetchPuck = mock.Mock(return_value="")
        self.robot = Robot(Queue.Queue())
        self.aGame = Game(self.robot, Queue.Queue())
        self.aGame.currentState = NearGoalPositionState(self.aGame)
        self.aGame.listOfPucks = [
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE),
            Puck(RANDOM_COLOR_CODE)
        ]
        self.aGame.setPucksOrientation("SA")
        self.aGame.setPositionToReadInLetterBoard(2)
        self.aGame.listOfPucks[0].setCornerToBePlaced("D")

    def test_whenGameDoAnActionStateGameStateShouldChangeAtTheEnd(self):
        self.aGame.doAction()
        self.assertTrue(self.aGame.getCurrentStateName() == "HasNoPuckState")

    def test_whenGameDoAnActionAtTheEndOneMorePuckShouldBePlaced(self):
        numberOfPucksPlacedAtStart = self.aGame.getNumberOfPucksPlaced()
        self.aGame.doAction()
        numberOfPucksPlacedAfter = self.aGame.getNumberOfPucksPlaced()
        self.assertTrue(numberOfPucksPlacedAfter > numberOfPucksPlacedAtStart)
Пример #24
0
 def setUp(self):
     Robot.initHardwareDevices = mock.Mock(return_value="")
     self.robot = Robot(Queue.Queue())
     self.game = Game(self.robot, Queue.Queue())