adding data path handling on session level
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from delta_barth.api import common
|
||||
from delta_barth.constants import DEFAULT_API_ERR_CODE, HTTP_BASE_CONTENT_HEADERS
|
||||
from delta_barth.constants import (
|
||||
DEFAULT_API_ERR_CODE,
|
||||
HTTP_BASE_CONTENT_HEADERS,
|
||||
LOG_FILENAME,
|
||||
)
|
||||
from delta_barth.errors import (
|
||||
UnspecifiedRequestType,
|
||||
)
|
||||
@@ -43,6 +48,25 @@ def test_session_set_DataPath(tmp_path):
|
||||
assert isinstance(session.data_path, Path)
|
||||
|
||||
|
||||
@patch("delta_barth.logging.ENABLE_LOGGING", True)
|
||||
@patch("delta_barth.logging.LOGGING_TO_FILE", True)
|
||||
def test_session_setup_logging(tmp_path):
|
||||
str_path = str(tmp_path)
|
||||
foldername: str = "logging_test"
|
||||
target_log_dir = tmp_path / foldername
|
||||
|
||||
session = common.Session(HTTP_BASE_CONTENT_HEADERS, logging_folder=foldername)
|
||||
session.set_data_path(str_path)
|
||||
log_dir = session.logging_dir
|
||||
assert log_dir.exists()
|
||||
assert log_dir == target_log_dir
|
||||
# write file
|
||||
target_file = target_log_dir / LOG_FILENAME
|
||||
assert not target_file.exists()
|
||||
session.setup() # calls setup code for logging
|
||||
assert target_file.exists()
|
||||
|
||||
|
||||
def test_validate_creds(credentials):
|
||||
creds = common.validate_credentials(
|
||||
username=credentials["user"],
|
||||
|
||||
Reference in New Issue
Block a user