Skip to content

Commit

Permalink
fix(test): update tests samples, fix copy_file method
Browse files Browse the repository at this point in the history
  • Loading branch information
maugde committed Jun 18, 2024
1 parent ffa5c79 commit b152232
Show file tree
Hide file tree
Showing 46 changed files with 57 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ def copy_files(self):
write or if self.target_dir already exists.
"""
for elt_path in self.source_dir.iterdir():
if elt_path.is_dir():
os.mkdir(self.target_dir.joinpath(elt_path.name))
logger.info(f"{elt_path.name} directory created.")
if elt_path.name not in EXCLUDED_FILES:
try:
if elt_path.is_file():
Expand Down Expand Up @@ -177,7 +174,7 @@ def start_server(self):
"""
args = [str(self.server_path)]
server_process = subprocess.Popen(args=args, start_new_session=True, cwd=self.target_dir)
time.sleep(1.5) # wait for the server to complete startup
time.sleep(2) # wait for the server to complete startup
if server_process.poll() is None:
logger.info("Server was started successfully.")

Expand Down
File renamed without changes.
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def get_version():
print("2.14.1")
print("2.14.4")


# entry point
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/samples/nt/AntaresWeb-2.15.2/AntaresWeb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.14.4"
Empty file.
21 changes: 21 additions & 0 deletions tests/samples/nt/AntaresWeb-2.15.2/AntaresWeb/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
This script simulates the behavior of an application and return its current version.
Support script for Windows systems
"""

import sys
import uvicorn


def get_version():
print("2.15.2")


# entry point
if __name__ == "__main__":
if "--version" in sys.argv or "-v" in sys.argv:
get_version()
elif len(sys.argv) == 1:
uvicorn.run("server:app", host="127.0.0.1", port=8080, log_level="info")
else:
print("Usage: AntaresWebServer [-v | --version]")
33 changes: 33 additions & 0 deletions tests/samples/nt/AntaresWeb-2.15.2/AntaresWeb/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
This script simulates the behavior of an application and return its current version.
Support script for Windows systems
"""

import asyncio
import contextlib
import os
import signal

from fastapi import FastAPI

TIMEOUT = 10 # duration in seconds of server execution


async def timer(duration: int):
await asyncio.sleep(duration)
os.kill(os.getpid(), signal.SIGTERM)


@contextlib.asynccontextmanager
async def lifespan(app: FastAPI):
# noinspection PyAsyncCall
asyncio.create_task(timer(TIMEOUT)) # launch server timeout
yield


app = FastAPI(lifespan=lifespan)


@app.get("/")
def index():
return {"response": "Successfully running"}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified tests/samples/posix/AntaresWeb/AntaresWebServer
100755 → 100644
Empty file.

0 comments on commit b152232

Please sign in to comment.