Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_FREEZE,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            players={
                'player':
                world.Player(login="******",
                             password="******",
                             ships=[
                                 default_ships.make_station(
                                     name="SweetHome",
                                     position=world.Position(
                                         x=0, y=0, velocity=world.Vector(0,
                                                                         0)),
                                     warehouse=ResourceContainerState({
                                         ResourceType.e_METALS:
                                         200000,
                                         ResourceType.e_SILICATES:
                                         40000,
                                     }),
                                 ),
                             ])
            },
            world=world.World(),
        )
    def __init__(self, *args, **kwargs):
        super(TestLogin, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_RUN,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            world=world.World(asteroids=world.Asteroids(asteroids=[
                world.Asteroid(position=world.Position(x=10000, y=10000),
                               radius=200,
                               composition={
                                   ResourceType.e_ICE: 20,
                                   ResourceType.e_SILICATES: 20,
                                   ResourceType.e_METALS: 20
                               })
            ])),
            players={
                'spy007':
                world.Player(login="******",
                             password="******",
                             ships=[
                                 default_ships.make_probe(
                                     name="scout-1",
                                     position=world.Position(100, 200))
                             ])
            })
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        super(TestNavigation, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_RUN,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            world=world.World(),
            players={
                'spy007': world.Player(
                    login="******",
                    password="******",
                    ships=[
                        default_ships.make_probe(
                            name="scout-1",
                            position=world.Position(
                                x=100, y=200, velocity=world.Vector(100, -100))),
                        default_ships.make_probe(
                            name="scout-2",
                            position=world.Position(
                                x=-100, y=-200, velocity=world.Vector(-10, 20)))
                    ]
                )
            }
        )
Beispiel #4
0
    async def run(self, configuration: Configuration):
        self.config_file.write(yaml.dump(configuration.to_pod()))
        self.config_file.close()

        server_bin = os.environ["SPEX_SERVER_BINARY"]
        self.server_process = subprocess.Popen(
            args=[server_bin, self.config_file.name],
            stdout=subprocess.PIPE)
        # Wait proces to start (but not more than 2 seconds)
        attempts = 40
        while attempts > 0 and not self.is_running():
            time.sleep(0.05)
            attempts -= 1
        assert self.is_running()

        # Run thread to read and store logs
        self.output_queue = await asyncio.wait_for(
            Server.create_async_queue(), timeout=1)

        def read_server_stdout():
            while self.is_running():
                line = self.server_process.stdout.readline().decode("UTF-8")
                self.output_queue.put(line)
        self.stdout_reader = threading.Thread(target=read_server_stdout)
        self.stdout_reader.daemon = True
        self.stdout_reader.start()

        found, _ = self.wait_log(substr="Server has been started", timeout=1)
        assert found
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_FREEZE,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            players={
                'oreman':
                world.Player(login="******",
                             password="******",
                             ships=[
                                 default_ships.make_miner(
                                     name="miner-1",
                                     position=world.Position(
                                         x=0, y=0, velocity=world.Vector(0,
                                                                         0))),
                             ])
            },
            world=world.World(asteroids=world.Asteroids(asteroids=[
                world.Asteroid(position=world.Position(x=10000, y=10000),
                               radius=200,
                               composition={
                                   world.ResourceType.e_ICE: 20,
                                   world.ResourceType.e_SILICATES: 20,
                                   world.ResourceType.e_METALS: 20
                               })
            ])),
        )
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_FREEZE,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            world=world.World(),
            players={
                'spy007': world.Player(login="******",
                                       password="******",
                                       ships=[])
            })
Beispiel #7
0
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_RUN,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            world=world.World(),
            players={
                'player':
                world.Player(login="******",
                             password="******",
                             ships=[
                                 default_ships.make_miner(
                                     name="miner-1",
                                     position=world.Position(
                                         x=0, y=0, velocity=world.Vector(0,
                                                                         0)),
                                     cargo=ResourceContainerState(
                                         content={
                                             ResourceType.e_SILICATES: 20000,
                                             ResourceType.e_METALS: 50000,
                                             ResourceType.e_ICE: 15000,
                                         })),
                                 default_ships.make_miner(
                                     name="miner-2",
                                     position=world.Position(
                                         x=10,
                                         y=10,
                                         velocity=world.Vector(0, 0)),
                                     cargo=ResourceContainerState(
                                         content={
                                             ResourceType.e_SILICATES: 5000,
                                             ResourceType.e_METALS: 5000,
                                             ResourceType.e_ICE: 10000,
                                         })),
                             ])
            },
        )
Beispiel #8
0
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

        self.configuration = Configuration(
            general=General(total_threads=1,
                            login_udp_port=7456,
                            initial_state=ApplicationMode.e_FREEZE,
                            ports_pool=(12000, 12100)),
            blueprints=blueprints.DefaultBlueprints(),
            players={
                'player':
                world.Player(login="******",
                             password="******",
                             ships=[
                                 default_ships.make_miner(
                                     name="miner",
                                     position=world.Position(
                                         x=0, y=0, velocity=world.Vector(0,
                                                                         0))),
                             ])
            },
            world=world.World(),
        )