class TestConfigHandler(unittest.TestCase):
    def setUp(self):
        path = os.path.join(os.path.curdir, "tests/test_config.json")
        config_handler = ConfigHandler(json.load(open(path)))
        user_configs = config_handler.handle()
        self.simulation = RushSimulation(user_configs=user_configs)

    def test_initializing(self):
        path = os.path.join(os.path.curdir, "tests/test_config.json")
        config_handler = ConfigHandler(json.load(open(path)))
        user_configs = config_handler.handle()
        simulation = RushSimulation(user_configs=user_configs)
        self.assertEqual(len(simulation.children), 2)

    def test_set_up(self):
        self.simulation.set_up()
        self.assertEqual(len(self.simulation.children), self.simulation.vehicle_amount + 2)
        self.assertEqual(len(self.simulation.vehicles), self.simulation.vehicle_amount)

    def test_start_pause(self):
        self.assertFalse(self.simulation.simulation_on)
        self.simulation.start()
        self.assertTrue(self.simulation.simulation_on)
        self.simulation.pause()
        self.assertFalse(self.simulation.simulation_on)

    def test_stop(self):
        self.assertFalse(self.simulation.simulation_on)
        self.simulation.start()
        self.assertTrue(self.simulation.simulation_on)
        self.simulation.stop()
        self.assertFalse(self.simulation.simulation_on)
Exemplo n.º 2
0
 def setUp(self):
     self.simulation = RushSimulation(user_configs=self.user_configs)
     self.vehicle = Vehicle(
         self.user_configs,
         target_vector=Vector(400, 600)
     )
     self.simulation.add_vehicle(self.vehicle)
Exemplo n.º 3
0
class TestBase(unittest.TestCase):
    path = os.path.join(os.path.curdir, 'tests/test_config.json')
    config_handler = ConfigHandler(json.load(open(path)))
    user_configs = config_handler.handle()

    def setUp(self):
        self.simulation = RushSimulation(user_configs=self.user_configs)
        self.vehicle = Vehicle(
            self.user_configs,
            target_vector=Vector(400, 600)
        )
        self.simulation.add_vehicle(self.vehicle)

    def tearDown(self):
        self.simulation.remove_vehicle(self.vehicle)
        self.simulation = None
 def setUp(self):
     path = os.path.join(os.path.curdir, "tests/test_config.json")
     config_handler = ConfigHandler(json.load(open(path)))
     user_configs = config_handler.handle()
     self.simulation = RushSimulation(user_configs=user_configs)