Skip to content
Snippets Groups Projects
Commit 464b60e1 authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

breakdown the line to allow for char lim

parent 07ffb8b7
No related branches found
No related tags found
1 merge request!28improve machine readable logging
Pipeline #369761 passed
......@@ -91,7 +91,7 @@ def read_metadata_from_logfile(logfile: Union[str, Path]) -> dict:
}
def set_up_logging(loglevel="warning", filename='gol.log'):
def set_up_logging(loglevel="warning", filename="gol.log"):
"""Set up logging.
This function sets up the logging configuration for the script.
......
"""Tests for mpsd-software-environment.py."""
import importlib
import logging
import os
import shutil
import subprocess
from pathlib import Path
import pytest
import logging
mod = importlib.import_module("mpsd-software-environment")
......@@ -315,20 +313,24 @@ def test_install_environment_zlib():
lines = f.read()
assert "zlib" in lines
def test_metadata_logging(tmp_path):
"""Test that metadata is logged and read correctly."""
# Test that the metadata is logged correctly
mod.set_up_logging(loglevel="debug", filename=tmp_path/"test-metadata.log")
mod.set_up_logging(loglevel="debug", filename=tmp_path / "test-metadata.log")
key = "important_key"
value = "important_value"
mod.log_metadata(key,value)
expected_log = f"{mod.config_vars['metadata_tag_open']}{key}:{value}{mod.config_vars['metadata_tag_close']}"
with open(tmp_path/"test-metadata.log", "r") as f:
mod.log_metadata(key, value)
open_tag = mod.config_vars["metadata_tag_open"]
close_tag = mod.config_vars["metadata_tag_close"]
expected_log = f"{open_tag}{key}:{value}{close_tag}"
with open(tmp_path / "test-metadata.log", "r") as f:
assert expected_log in f.read()
# Test that the metadata is read correctly
read_dict = mod.read_metadata_from_logfile(tmp_path/"test-metadata.log")
read_dict = mod.read_metadata_from_logfile(tmp_path / "test-metadata.log")
assert read_dict[key] == value
def test_interface(tmp_path):
"""Test other things (not implemented yet)."""
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment