def testStep_callsSetOrientation_whenIsCollisionIsTrue(self): global setOrientationCalled setOrientationCalled = False setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.step() self.assertEqual(True, setOrientationCalled)
def testStep_setsFinishedStateToTrueWhenNextPosIsFirstCollisionPos(self): setupFakes(self, ori = self.b.ORIENTATION_RIGHT, collision = False, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.mObj.expandMap(6, 6, True, True) b.firstCollision = c.Coordinate(3, 4) b.pos = c.Coordinate(2, 4) b.step() self.assertEqual(True, b.finished)
def testStep_doesNotCallMoveWhenIsCollisionIsTrue(self): global moveCalled moveCalled = False self.outputs["move"] = fakeMove setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.step() self.assertEqual(False, moveCalled)
def testStep_translatesFirstCollisionPosWhenPrependingVertically(self): global getOrientationValue global isCollisionValue setupFakes(self, ori = self.b.ORIENTATION_RIGHT, collision = True, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.step() getOrientationValue = setOrientationValue isCollisionValue = False b.step() getOrientationValue = setOrientationValue isCollisionValue = False b.step() self.assertEqual(c.Coordinate(1, 3), b._getFirstCollisionPos())
def setUp(self): self.cls = theseusBrain.TheseusBrain self.inputs = {"isCollision": fakeCallback, "getOrientation": fakeCallback, "getMovementDirection": fakeCallback, "isRightCollision": fakeCallback, "isBackCollision": fakeCallback, "isLeftCollision": fakeCallback} self.outputs = {"setOrientation": fakeCallback, "setMovementDirection": fakeCallback, "move": fakeCallback} self.b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
def testStep_storesFirstCollision(self): setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.step() self.assertEqual(c.Coordinate(1, 1), b._getFirstCollisionPos())
def testStep_translatesStartPositionWhenPrependingBrainMapHorizontally(self): setupFakes(self, ori = self.b.ORIENTATION_LEFT, collision = True, direction = self.b.DIRECTION_FOREWARD) b = theseusBrain.TheseusBrain(self.inputs, self.outputs) b.step() self.assertEqual(c.Coordinate(2, 1), b._getStartPosition())