def test_PotatoShouldDescendIfThereIsNotTileBehind(self): startPosition = Point(2,4) expectedPosition = Point(60, 128) keysPressed = [] self.enviroment.isTile.side_effect = [False, False] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoJumping.png'))) self.spriteManagerExpected.append(call.flipSpriteImage()) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(2,5))) self.enviromentExpected.append(call.isTile(Point(2,5))) self.soundManagerExpected.append(call.getSound().play()) self.target.setActualPosition(startPosition) self.target.motion(keysPressed) self.assertEqual(self.target.ActualPosition, expectedPosition) self.assertFalse(self.target.isStanding) self.assertTrue(self.target.isGoingDown) self.assertTrue(self.target.isJumping)
def test_PotatoDie(self): startPosition = Point(1,20) startCords = Point(0,1) expectedPosition = Point(startCords.X*30,startCords.Y*30) keysPressed = [] self.enviroment.getStartCords.return_value = startCords self.enviroment.isTile.side_effect = [False] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoStanding.png'))) self.spriteManagerExpected.append(call.flipSpriteImage()) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(1,21))) self.enviromentExpected.append(call.getStartCords()) self.soundManagerExpected.append(call.getSound().play()) self.target.setActualPosition(startPosition) self.target.isJumping = True self.target.isGoingDown = True self.target.motion(keysPressed) self.assertEqual(expectedPosition, self.target.ActualPosition)
def test_PotatoReachCheckpointTrue(self): startPosition = Point(10,1) finishCord = startPosition expectedPosition = Point(startPosition.X*30,startPosition.Y*30) keysPressed = [] self.enviroment.getFinishCords.return_value = finishCord self.enviroment.isTile.side_effect = [True] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoStanding.png'))) self.spriteManagerExpected.append(call.flipSpriteImage()) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(10,2))) self.soundManagerExpected.append(call.getSound().play()) self.target.setActualPosition(startPosition) self.target.motion(keysPressed) self.assertTrue(self.target.reachCheckpoint)
def test_ShouldNotMoveIfThereIsTileGoingRight(self): startPosition = Point(2,4) expectedPosition = Point(56, startPosition.Y*30) keysPressed = [Key.A] self.enviroment.isTile.side_effect = [False, True] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoWalking.png'))) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.isTile(Point(1,4))) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(2,5))) self.target.setActualPosition(startPosition) self.target.motion(keysPressed) self.assertEqual(self.target.ActualPosition, expectedPosition)
def test_MovePotatoLeftInTheEdgeOfTheScreen(self): startCord = Point(0,0) expectedPosition = Point(600, 0) self.enviroment.isTile.side_effect = [False, True, True] keysPressed = [Key.A] self.target.setActualPosition(startCord) self.target.motion(keysPressed) self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoWalking.png'))) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.isTile(Point(-1,0))) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(20,1))) self.assertTrue(self.target.isGoingLeft) self.assertFalse(self.target.isStanding)
def test_MovePotatoRight(self): keysPressed = [Key.D] startPosition = Point(1,0) expectedPosition = Point(startPosition.X*30 + 4, startPosition.Y) self.enviroment.isTile.side_effect = [False, True] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoWalking.png'))) self.spriteManagerExpected.append(call.flipSpriteImage()) self.spriteManagerExpected.append(call.updateSprite(expectedPosition.X, expectedPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.isTile(Point(2,0))) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(1,1))) self.target.setActualPosition(startPosition) self.target.isGoingRight = True self.target.motion(keysPressed) self.assertFalse(self.target.isGoingLeft) self.assertFalse(self.target.isStanding)
def test_MovePotato(self): startPosition = Point(1,0) keysPressed = [] self.enviroment.isTile.side_effect = [True] self.spriteManagerExpected.append(call.updateSpriteImage( os.path.join('JumperPY', 'bin','Resources', 'potatoStanding.png'))) self.spriteManagerExpected.append(call.flipSpriteImage()) self.spriteManagerExpected.append(call.updateSprite(startPosition.X*30, startPosition.Y)) self.enviromentExpected.append(call.getStartCords()) self.enviromentExpected.append(call.getFinishCords()) self.enviromentExpected.append(call.isTile(Point(1,1))) self.target.setActualPosition(startPosition) self.target.motion(keysPressed) self.assertTrue(self.target.isStanding)