def test_checkCollisions_oneCollisionDetectedWhenMultipleEntitiesPresent(self): entityToTest, collidedEntity = Entity(), Entity() distantEntity1, distantEntity2 = Entity(), Entity() distantEntity1.x, distantEntity1.y = 500, 500 distantEntity2.x, distantEntity2.y = 800, 800 entities.extend([collidedEntity, distantEntity1, distantEntity2]) entityToTest.check_collisions() self.assertListEqual(collisions, [(entityToTest, collidedEntity)])
def test_insideYBoundary_falseWhenEntityYPosIsNegative(self): entityToTest = Entity() entityToTest.y = -1 self.assertFalse(entityToTest.inside_y_boundary())
def test_insideXBoundary_falseWhenEntityXPosGreaterThanScreenWidth(self): entityToTest = Entity() entityToTest.x = WIDTH + 1 self.assertFalse(entityToTest.inside_x_boundary())
def test_insideXBoundary_falseWhenEntityXPosIsNegative(self): entityToTest = Entity() entityToTest.x = -1 self.assertFalse(entityToTest.inside_x_boundary())
def test_checkCollisions_emptyCollisionsListWhenOtherEntityXPosEqualsSpriteSize(self): entityToTest, otherEntity = Entity(), Entity() otherEntity.x += SPRITE_SIZE entities.append(otherEntity) entityToTest.check_collisions() self.assertFalse(collisions)
def test_checkCollisions_oneCollisionDetectedWhenOtherEntityXPosLessThanSpriteSize(self): entityToTest, otherEntity = Entity(), Entity() otherEntity.x += SPRITE_SIZE-1 entities.append(otherEntity) entityToTest.check_collisions() self.assertListEqual(collisions, [(entityToTest, otherEntity)])
def test_checkCollisions_emptyCollisionsListWhenNoOtherEntities(self): entityToTest = Entity() entityToTest.check_collisions() self.assertFalse(collisions)
def test_checkCollisions_entityDoesNotCollideWithSelf(self): entityToTest = Entity() entities.append(entityToTest) entityToTest.check_collisions() self.assertFalse(collisions)
def test_checkCollisions_collisionsListContainsCollidedEntities(self): entityToTest = Entity() entityCollidedWith = Entity() entities.append(entityCollidedWith) entityToTest.check_collisions() self.assertListEqual(collisions, [(entityToTest, entityCollidedWith)])
def test_insideXBoundary_falseWhenEntityYPosGreaterThanScreenHeight(self): entityToTest = Entity() entityToTest.y = HEIGHT + 1 self.assertFalse(entityToTest.inside_y_boundary())