def setUpClass(self): self.swarm_config = load_json_config("swarm_config") self.swarm = Swarm(self.swarm_config.Swarm) self.ip = self.swarm.ip self.webport = self.swarm.webport self.swarmSize = 0 self.swarm_data_structure = { "Swarm": { "size": self.swarmSize, "ip": self.ip, "webport": self.webport }, "Drones": [] } for idx, drone_cfg in enumerate(self.swarm_config.Drones): drone = Drone(drone_cfg) self.swarm_data_structure.get("Drones").append(drone) self.swarmSize = idx #idx is zero based so we make is not self.swarmSize += 1 ###################################### print("Setup testConfig() complete!")
return False def ipArgsExists(): if args.ip: return True return False def instance_arg_exists(): if args.instance: return True return False swarm_config = load_json_config('swarm_config') default_id = 1 default_ip = '127.0.0.1' # change depending on drone's role - 192.168.1.[1-10] default_port = '5760' default_webport = '5000' default_connection_string = default_ip + ":" + default_port instance = 0 sitl = True if sitlArgExists(): sitl = args.sitl if connectionArgExists(): default_connection_string = args.connection_string
def test_add_to_swarm(self): swarm_config = load_json_config("swarm_config") self.swarm = Swarm(swarm_config.Swarm) for idx, drone in enumerate(self.swarm_data_structure.get("Drones")): self.swarm.add_drone(self.drones[idx]) self.assertTrue(self.swarm.swarmSize(), idx + 1)
def test_swarm(self): swarm_config = load_json_config("swarm_config") self.swarm = Swarm(swarm_config.Swarm) self.assertTrue(self.swarm)