Make pytest patch with temporary session dir
This commit is contained in:
@@ -2,7 +2,7 @@ training_config:
|
||||
rl_framework: SB3
|
||||
rl_algorithm: PPO
|
||||
seed: 333
|
||||
n_learn_steps: 0
|
||||
n_learn_episodes: 0
|
||||
n_eval_episodes: 5
|
||||
max_steps_per_episode: 128
|
||||
deterministic_eval: false
|
||||
|
||||
@@ -2,7 +2,7 @@ training_config:
|
||||
rl_framework: SB3
|
||||
rl_algorithm: PPO
|
||||
seed: 333
|
||||
n_learn_steps: 2560
|
||||
n_learn_episodes: 10
|
||||
n_eval_episodes: 5
|
||||
max_steps_per_episode: 128
|
||||
deterministic_eval: false
|
||||
|
||||
@@ -2,7 +2,7 @@ training_config:
|
||||
rl_framework: SB3
|
||||
rl_algorithm: PPO
|
||||
seed: 333
|
||||
n_learn_steps: 2560
|
||||
n_learn_episodes: 10
|
||||
n_eval_episodes: 0
|
||||
max_steps_per_episode: 128
|
||||
deterministic_eval: false
|
||||
|
||||
@@ -5,7 +5,6 @@ import tempfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
import nodeenv
|
||||
import pytest
|
||||
@@ -22,13 +21,15 @@ from primaite.simulator.network.transmission.transport_layer import Port
|
||||
from primaite.simulator.system.applications.application import Application
|
||||
from primaite.simulator.system.core.sys_log import SysLog
|
||||
from primaite.simulator.system.services.service import Service
|
||||
from tests.mock_and_patch.get_session_path_mock import get_temp_session_path
|
||||
from tests.mock_and_patch.get_session_path_mock import temp_user_sessions_path
|
||||
|
||||
ACTION_SPACE_NODE_VALUES = 1
|
||||
ACTION_SPACE_NODE_ACTION_VALUES = 1
|
||||
|
||||
_LOGGER = getLogger(__name__)
|
||||
|
||||
from primaite import PRIMAITE_PATHS
|
||||
|
||||
# PrimAITE v3 stuff
|
||||
from primaite.simulator.file_system.file_system import FileSystem
|
||||
from primaite.simulator.network.hardware.base import Node
|
||||
@@ -97,8 +98,9 @@ class TempPrimaiteSession(PrimaiteSession):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_primaite_session(request) -> TempPrimaiteSession:
|
||||
def temp_primaite_session(request, monkeypatch) -> TempPrimaiteSession:
|
||||
"""Create a temporary PrimaiteSession object."""
|
||||
|
||||
config_path = request.param[0]
|
||||
return TempPrimaiteSession.from_config(config_path=config_path)
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(PRIMAITE_PATHS, "user_sessions_path", temp_user_sessions_path())
|
||||
config_path = request.param[0]
|
||||
return TempPrimaiteSession.from_config(config_path=config_path)
|
||||
|
||||
@@ -9,7 +9,7 @@ from primaite import getLogger
|
||||
_LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
def get_temp_session_path(session_timestamp: datetime) -> Path:
|
||||
def temp_user_sessions_path() -> Path:
|
||||
"""
|
||||
Get a temp directory session path the test session will output to.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user