Skip to content

Commit

Permalink
fix(tests.integration): fix dependency missing
Browse files Browse the repository at this point in the history
  • Loading branch information
maugde committed Aug 29, 2024
1 parent e7552a8 commit e334bb7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 50 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies = [
'pywin32<=306; sys_platform == "win32"',
'httpx<0.28',
'platformdirs<=4.2.2',
'uvicorn',
]

[project.urls]
Expand All @@ -52,10 +53,12 @@ dependencies = [
"fastapi",
"pyinstaller",
"httpx==0.27.0",
"requests",
"platformdirs==4.2.2",
"uvicorn",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test = "pytest {args:tests} --basetemp=target"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
Expand Down
3 changes: 1 addition & 2 deletions src/antares_web_installer/gui/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@


class InstallationThread(Thread):
def __init__(self, group=None, target=None, name=None,
args=(), kwargs=None, *, daemon=None):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None):
super().__init__(group, target, name, args, kwargs, daemon=daemon)

def run(self):
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
from typing import List

import pytest

from pathlib import Path
Expand All @@ -9,15 +11,17 @@


@pytest.fixture(name="antares_web_server_paths", scope="session", autouse=True)
def antares_web_server_paths_fixture(tmp_path_factory: pytest.TempPathFactory) -> [Path]:
def antares_web_server_paths_fixture(tmp_path_factory: pytest.TempPathFactory) -> List[Path]:
"""Fixture used to build both the Antares web server version (2.14.4 and 2.15.2)."""
target_dir = tmp_path_factory.mktemp("servers", numbered=False)

apps = []
for version in ["2.14.4", "2.15.2"]:
import tests.integration.server_mock.server as server

server.__dict__["version"] = version
version_target_dir = target_dir.joinpath("AntaresWeb-"+version)
version_target_dir = target_dir.joinpath("AntaresWeb-" + version)
apps.append(build(version_target_dir, exe_name=EXE_NAME))

print("servers built: {}".format(apps))
return apps
3 changes: 1 addition & 2 deletions tests/integration/server_mock/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
This server will only run 10 seconds, so it is not suitable for long tests.
"""
import argparse

import argparse
import uvicorn

from tests.integration.server_mock.web import app

# Define the server configuration
Expand Down
18 changes: 3 additions & 15 deletions tests/integration/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ class TestApp:
"""
Integration tests for the app
"""
def test_run__empty_target(
self,
downloaded_dir: Path,
program_dir: Path,
settings: None
) -> None:

def test_run__empty_target(self, downloaded_dir: Path, program_dir: Path, settings: None) -> None:
"""
The goal of this test is to verify the behavior of the application when:
- The Antares server is not running
Expand All @@ -88,13 +84,7 @@ def test_run__empty_target(
app = App(source_dir=application_dir, target_dir=program_dir, shortcut=True, launch=True)
app.run()

def test_shortcut__created(
self,
downloaded_dir: Path,
program_dir: Path,
desktop_dir: Path,
settings: None
):
def test_shortcut__created(self, downloaded_dir: Path, program_dir: Path, desktop_dir: Path, settings: None):
for application_dir in downloaded_dir.iterdir():
# Run the application
app = App(source_dir=application_dir, target_dir=program_dir, shortcut=True, launch=True)
Expand All @@ -116,5 +106,3 @@ def test_shortcut__not_created(self):
@return:
"""
pass


28 changes: 0 additions & 28 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import hashlib
from pathlib import Path

from _pytest.monkeypatch import MonkeyPatch

from antares_web_installer.app import App, EXCLUDED_FILES


Expand Down Expand Up @@ -40,25 +37,6 @@ def test_install_files__from_scratch(self, tmp_path: Path) -> None:
for name in expected_files:
assert (target_dir / name).exists(), f"File {name} must be copied"

def test_install_files__update_config(self, datadir: Path, monkeypatch: MonkeyPatch) -> None:
# Replace the original `check_version` method with a mock
monkeypatch.setattr(App, "check_version", lambda _: "2.14")

# Prepare the test resources
source_dir = datadir.joinpath("install_files/source_files")
target_dir = datadir.joinpath("install_files/target_files")
old_config = (target_dir / "config.yaml").read_text()

app = App(source_dir=source_dir, target_dir=target_dir)
app.install_files()

# Check that `dummy.txt` has been copied
assert (target_dir / "dummy.txt").exists()

# Check that the config file has been updated
new_config = (target_dir / "config.yaml").read_text()
assert old_config != new_config

def test_copy_files__nominal_case(self, datadir: Path) -> None:
# Prepare the test resources
source_dir = datadir.joinpath("copy_files/source_files")
Expand Down Expand Up @@ -92,9 +70,3 @@ def test_check_version(self, tmp_path: Path) -> None:
# 2. Le programme exécutable existe, mais le programme plante => InstallError
# 3. Le programme exécutable existe et fonctionne => pas d'erreur
pass

def test_create_icons(self) -> None:
pass

def test_start_server(self) -> None:
pass

0 comments on commit e334bb7

Please sign in to comment.