def test_topCoordinates(self):
		roomObj = room(5, 5)
		self.assertEqual(roomObj.topCoordinates, (5, 5))
		clearSingleton()
		with self.assertRaises(Exception) as context:
			roomObj = room(5, -5)
		self.assertTrue('Improper Input' in str(context.exception))
		clearSingleton()
Esempio n. 2
0
	def test_navigate(self):
		roomObj = room(5, 5)

		insectObj1 = insect(room=roomObj, initialX=1, initialY=2, initialDirection="N")
		insectObj1.navigate("LFLFLFLFF")
		self.assertEqual(insectObj1.coordinates, (1, 3, "N"))

		with self.assertRaises(Exception) as context:
			insectObj2 = insect(room=roomObj, initialX=6, initialY=2, initialDirection="N")
		self.assertTrue('out of Bounds of Room' in str(context.exception))
Esempio n. 3
0
from robots import insect
from buildings import room

if __name__ == "__main__":
	try:
		roomX, roomY = map(int, raw_input().strip().split(" "))
		roomObj = room(roomX, roomY)
		while True:
			insectCoordinates = raw_input().strip().split(" ")
			if len(insectCoordinates) != 3:
				break
			insectInstructions = raw_input()
			if insectInstructions == "":
				break
			insectObj = insect(room=roomObj, initialX=int(insectCoordinates[0]),
							   initialY=int(insectCoordinates[1]), initialDirection=insectCoordinates[2])
			insectObj.navigate(insectInstructions)
			finalCoordinates = insectObj.coordinates
			print finalCoordinates[0], finalCoordinates[1], finalCoordinates[2]
	except Exception as e:
		print e, " some problem"  # just log it
	def test_bottomCoordinates(self):
		roomObj = room(5, 5)
		self.assertEqual(roomObj.bottomCoordinates, (0, 0))
		clearSingleton()
Esempio n. 5
0
	def test_coordinates(self):
		roomObj = room(5, 5)
		insectObj1 = insect(room=roomObj, initialX=1, initialY=2, initialDirection="N")
		self.assertEqual(insectObj1.coordinates, (1, 2, "N"))