From ff4f649c04365bfc57a27028b19403fadb647bad Mon Sep 17 00:00:00 2001 From: Brian Gunnarson Date: Fri, 13 Sep 2024 12:11:18 -0700 Subject: [PATCH] run fix-style --- merlin/server/server_commands.py | 2 +- tests/unit/server/test_server_commands.py | 145 +++++++++++++--------- tests/unit/server/test_server_config.py | 112 +++++++++-------- 3 files changed, 144 insertions(+), 115 deletions(-) diff --git a/merlin/server/server_commands.py b/merlin/server/server_commands.py index 7266007d..b0015473 100644 --- a/merlin/server/server_commands.py +++ b/merlin/server/server_commands.py @@ -199,7 +199,7 @@ def check_for_not_running_server() -> bool: if current_status in status_errors: LOG.info(status_errors[current_status]) return False - + return True diff --git a/tests/unit/server/test_server_commands.py b/tests/unit/server/test_server_commands.py index 2deb64c8..4261a1f8 100644 --- a/tests/unit/server/test_server_commands.py +++ b/tests/unit/server/test_server_commands.py @@ -1,13 +1,15 @@ """ Tests for the `server_commands.py` module. """ + import logging import os -import pytest import subprocess from argparse import Namespace from typing import Dict, List +import pytest + from merlin.server.server_commands import ( check_for_not_running_server, config_server, @@ -17,7 +19,7 @@ start_redis_container, start_server, status_server, - stop_server + stop_server, ) from merlin.server.server_config import ServerStatus from merlin.server.server_util import ServerConfig @@ -75,10 +77,13 @@ def test_config_server_no_server_config( assert 'Try to run "merlin server init" again to reinitialize values.' in caplog.text -@pytest.mark.parametrize("server_status, status_name", [ - (ServerStatus.RUNNING, "running"), - (ServerStatus.NOT_RUNNING, "not_running"), -]) +@pytest.mark.parametrize( + "server_status, status_name", + [ + (ServerStatus.RUNNING, "running"), + (ServerStatus.NOT_RUNNING, "not_running"), + ], +) def test_config_server_add_user_remove_user_success( mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 @@ -93,7 +98,7 @@ def test_config_server_add_user_remove_user_success( the server status being set to RUNNING. For each scenario we should expect: - RUNNING -> RedisUsers.write and RedisUsers.apply_to_redis are both called twice - NOT_RUNNING -> RedisUsers.write is called twice and RedisUsers.apply_to_redis is not called at all - + :param mocker: A built-in fixture from the pytest-mock library to create a Mock object :param caplog: A built-in fixture from the pytest library to capture logs :param server_testing_dir: The path to the the temp output directory for server tests @@ -130,7 +135,6 @@ def test_config_server_add_user_remove_user_failure( caplog: "Fixture", # noqa: F821 server_config_server_args: Namespace, server_server_config: Dict[str, Dict[str, str]], - ): """ Test the `config_server` function by attempting to add a user that already exists (we do this through mock) @@ -160,12 +164,21 @@ def test_config_server_add_user_remove_user_failure( assert f"User '{user_to_add_and_remove}' doesn't exist within current users." in caplog.text -@pytest.mark.parametrize("server_status, expected_log_msgs", [ - (ServerStatus.NOT_INITIALIZED, ["Merlin server has not been initialized.", "Please initalize server by running 'merlin server init'"]), - (ServerStatus.MISSING_CONTAINER, ["Unable to find server image.", "Ensure there is a .sif file in merlin server directory."]), - (ServerStatus.NOT_RUNNING, ["Merlin server is not running."]), - (ServerStatus.RUNNING, ["Merlin server is running."]), -]) +@pytest.mark.parametrize( + "server_status, expected_log_msgs", + [ + ( + ServerStatus.NOT_INITIALIZED, + ["Merlin server has not been initialized.", "Please initalize server by running 'merlin server init'"], + ), + ( + ServerStatus.MISSING_CONTAINER, + ["Unable to find server image.", "Ensure there is a .sif file in merlin server directory."], + ), + (ServerStatus.NOT_RUNNING, ["Merlin server is not running."]), + (ServerStatus.RUNNING, ["Merlin server is running."]), + ], +) def test_status_server( mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 @@ -187,13 +200,28 @@ def test_status_server( assert expected_log_msg in caplog.text -@pytest.mark.parametrize("server_status, expected_result, expected_log_msg", [ - (ServerStatus.NOT_INITIALIZED, False, "Merlin server has not been intitialized. Please run 'merlin server init' first."), - (ServerStatus.MISSING_CONTAINER, False, "Merlin server has not been intitialized. Please run 'merlin server init' first."), - (ServerStatus.NOT_RUNNING, True, None), - (ServerStatus.RUNNING, False, """Merlin server already running. - Stop current server with 'merlin server stop' before attempting to start a new server."""), -]) +@pytest.mark.parametrize( + "server_status, expected_result, expected_log_msg", + [ + ( + ServerStatus.NOT_INITIALIZED, + False, + "Merlin server has not been intitialized. Please run 'merlin server init' first.", + ), + ( + ServerStatus.MISSING_CONTAINER, + False, + "Merlin server has not been intitialized. Please run 'merlin server init' first.", + ), + (ServerStatus.NOT_RUNNING, True, None), + ( + ServerStatus.RUNNING, + False, + """Merlin server already running. + Stop current server with 'merlin server stop' before attempting to start a new server.""", + ), + ], +) def test_check_for_not_running_server( mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 @@ -248,7 +276,7 @@ def test_start_redis_container_invalid_image_path( assert start_redis_container(ServerConfig(server_server_config)) is None assert f"Unable to find image at {os.path.join(server_testing_dir, image_file)}" in caplog.text - + def test_start_redis_container_invalid_config_path( mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 @@ -301,7 +329,7 @@ def test_server_started_no_redis_start(mocker: "Fixture", caplog: "Fixture"): # """ mock_process = mocker.Mock() mock_process.stdout = mocker.Mock() - + expected_redis_out_msg = "Reached end of redis output without seeing 'Ready to accept connections'" mocker.patch("merlin.server.server_commands.parse_redis_output", return_value=(False, expected_redis_out_msg)) @@ -327,9 +355,8 @@ def test_server_started_process_file_dump_fail( mock_process = mocker.Mock() mock_process.pid = 1234 mock_process.stdout = mocker.Mock() - + image_pid = 5678 - expected_redis_out_msg = "Reached end of redis output without seeing 'Ready to accept connections'" mocker.patch("merlin.server.server_commands.parse_redis_output", return_value=(True, {"pid": image_pid})) mocker.patch("merlin.server.server_commands.dump_process_file", return_value=False) @@ -337,11 +364,14 @@ def test_server_started_process_file_dump_fail( assert "Unable to create process file for container." in caplog.text -@pytest.mark.parametrize("server_status", [ - ServerStatus.NOT_RUNNING, - ServerStatus.MISSING_CONTAINER, - ServerStatus.NOT_INITIALIZED, -]) +@pytest.mark.parametrize( + "server_status", + [ + ServerStatus.NOT_RUNNING, + ServerStatus.MISSING_CONTAINER, + ServerStatus.NOT_INITIALIZED, + ], +) def test_server_started_server_not_running( mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 @@ -360,9 +390,8 @@ def test_server_started_server_not_running( mock_process = mocker.Mock() mock_process.pid = 1234 mock_process.stdout = mocker.Mock() - + image_pid = 5678 - expected_redis_out_msg = "Reached end of redis output without seeing 'Ready to accept connections'" mocker.patch("merlin.server.server_commands.parse_redis_output", return_value=(True, {"pid": image_pid})) mocker.patch("merlin.server.server_commands.dump_process_file", return_value=True) mocker.patch("merlin.server.server_commands.get_server_status", return_value=server_status) @@ -371,7 +400,7 @@ def test_server_started_server_not_running( assert "Unable to start merlin server." in caplog.text -def test_server_started_no_issues(mocker: "Fixture",server_server_config: Dict[str, Dict[str, str]]): # noqa: F821 +def test_server_started_no_issues(mocker: "Fixture", server_server_config: Dict[str, Dict[str, str]]): # noqa: F821 """ Test the `server_started` function with no issues starting the server. This should return True. @@ -383,13 +412,9 @@ def test_server_started_no_issues(mocker: "Fixture",server_server_config: Dict[s mock_process = mocker.Mock() mock_process.pid = 1234 mock_process.stdout = mocker.Mock() - + image_pid = 5678 - expected_redis_out_msg = "Reached end of redis output without seeing 'Ready to accept connections'" - mocker.patch( - "merlin.server.server_commands.parse_redis_output", - return_value=(True, {"pid": image_pid, "port": 6379}) - ) + mocker.patch("merlin.server.server_commands.parse_redis_output", return_value=(True, {"pid": image_pid, "port": 6379})) mocker.patch("merlin.server.server_commands.dump_process_file", return_value=True) mocker.patch("merlin.server.server_commands.get_server_status", return_value=ServerStatus.RUNNING) @@ -472,15 +497,16 @@ def test_start_server_successful_start( assert start_server() -@pytest.mark.parametrize("server_status", [ - ServerStatus.NOT_RUNNING, - ServerStatus.MISSING_CONTAINER, - ServerStatus.NOT_INITIALIZED, -]) +@pytest.mark.parametrize( + "server_status", + [ + ServerStatus.NOT_RUNNING, + ServerStatus.MISSING_CONTAINER, + ServerStatus.NOT_INITIALIZED, + ], +) def test_stop_server_server_not_running( - mocker: "Fixture", # noqa: F821 - caplog: "Fixture", # noqa: F821 - server_status: ServerStatus + mocker: "Fixture", caplog: "Fixture", server_status: ServerStatus # noqa: F821 # noqa: F821 ): """ Test the `stop_server` function with a server that's not running. This should log two messages @@ -497,7 +523,7 @@ def test_stop_server_server_not_running( assert "Start a merlin server first with 'merlin server start'" in caplog.text -def test_stop_server_no_server_config(mocker: "Fixture", caplog: "Fixture"): +def test_stop_server_no_server_config(mocker: "Fixture", caplog: "Fixture"): # noqa: F821 """ Test the `stop_server` function with no server config being pulled. This should log a message and return False. @@ -569,7 +595,9 @@ def test_stop_server_stop_command_is_not_kill( :param caplog: A built-in fixture from the pytest library to capture logs :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class """ - mocker.patch("merlin.server.server_commands.get_server_status", side_effect=[ServerStatus.RUNNING, ServerStatus.NOT_RUNNING]) + mocker.patch( + "merlin.server.server_commands.get_server_status", side_effect=[ServerStatus.RUNNING, ServerStatus.NOT_RUNNING] + ) mocker.patch("merlin.server.server_commands.pull_server_config", return_value=ServerConfig(server_server_config)) mocker.patch("merlin.server.server_commands.pull_process_file", return_value={"parent_pid": 123}) custom_stop_command = "not a kill command" @@ -580,16 +608,15 @@ def test_stop_server_stop_command_is_not_kill( mock_run.assert_called_with(custom_stop_command.split(), stdout=subprocess.PIPE) -@pytest.mark.parametrize("server_status", [ - ServerStatus.NOT_RUNNING, - ServerStatus.MISSING_CONTAINER, - ServerStatus.NOT_INITIALIZED, -]) -def test_restart_server_server_not_running( - mocker: "Fixture", # noqa: F821 - caplog: "Fixture", # noqa: F821 - server_status: ServerStatus -): +@pytest.mark.parametrize( + "server_status", + [ + ServerStatus.NOT_RUNNING, + ServerStatus.MISSING_CONTAINER, + ServerStatus.NOT_INITIALIZED, + ], +) +def test_restart_server_server_not_running(mocker: "Fixture", caplog: "Fixture", server_status: ServerStatus): # noqa: F821 """ Test the `restart_server` function with a server that's not running. This should log two messages and return False. diff --git a/tests/unit/server/test_server_config.py b/tests/unit/server/test_server_config.py index 092aa6eb..2528648d 100644 --- a/tests/unit/server/test_server_config.py +++ b/tests/unit/server/test_server_config.py @@ -7,13 +7,11 @@ import os import string from typing import Dict, Tuple, Union -import yaml import pytest +import yaml -from merlin.server.server_util import CONTAINER_TYPES, MERLIN_SERVER_SUBDIR, ServerConfig from merlin.server.server_config import ( - LOCAL_APP_YAML, MERLIN_CONFIG_DIR, PASSWORD_LENGTH, ServerStatus, @@ -29,6 +27,8 @@ pull_server_image, write_container_command_files, ) +from merlin.server.server_util import CONTAINER_TYPES, MERLIN_SERVER_SUBDIR, ServerConfig + try: from importlib import resources @@ -136,7 +136,7 @@ def test_write_container_command_files_with_existing_files( :param server_testing_dir: The path to the the temp output directory for server tests """ caplog.set_level(logging.INFO) - mocker.patch('os.path.exists', return_value=True) + mocker.patch("os.path.exists", return_value=True) assert write_container_command_files(server_testing_dir) file_names = [f"{container}.yaml" for container in CONTAINER_TYPES] for file in file_names: @@ -159,7 +159,7 @@ def test_write_container_command_files_with_nonexisting_files( caplog.set_level(logging.INFO) # Mock the os.path.exists function so it returns False - mocker.patch('os.path.exists', return_value=False) + mocker.patch("os.path.exists", return_value=False) # Mock the resources.path context manager mock_path = mocker.patch("merlin.server.server_config.resources.path") @@ -209,7 +209,7 @@ def test_create_server_config_merlin_config_dir_nonexistent( :param server_testing_dir: The path to the the temp output directory for server tests """ nonexistent_dir = f"{server_testing_dir}/merlin_config_dir" - mocker.patch('merlin.server.server_config.MERLIN_CONFIG_DIR', nonexistent_dir) + mocker.patch("merlin.server.server_config.MERLIN_CONFIG_DIR", nonexistent_dir) assert not create_server_config() assert f"Unable to find main merlin configuration directory at {nonexistent_dir}" in caplog.text @@ -230,8 +230,8 @@ def test_create_server_config_server_subdir_nonexistent_oserror( # Mock MERLIN_CONFIG_DIR and MERLIN_SERVER_SUBDIR nonexistent_server_subdir = "test_create_server_config_server_subdir_nonexistent" - mocker.patch('merlin.server.server_config.MERLIN_CONFIG_DIR', server_testing_dir) - mocker.patch('merlin.server.server_config.MERLIN_SERVER_SUBDIR', nonexistent_server_subdir) + mocker.patch("merlin.server.server_config.MERLIN_CONFIG_DIR", server_testing_dir) + mocker.patch("merlin.server.server_config.MERLIN_SERVER_SUBDIR", nonexistent_server_subdir) # Mock os.mkdir so it raises an OSError err_msg = "File not writeable" @@ -257,7 +257,7 @@ def test_create_server_config_no_server_config( # Mock the necessary variables/functions to get us to the pull_server_config call mocker.patch("merlin.server.server_config.MERLIN_CONFIG_DIR", server_testing_dir) mocker.patch("merlin.server.server_config.write_container_command_files", return_value=True) - mock_open_func = mocker.mock_open(read_data='key: value') + mock_open_func = mocker.mock_open(read_data="key: value") mocker.patch("builtins.open", mock_open_func) # Mock the pull_server_config call (what we're actually testing) and run the test @@ -287,7 +287,7 @@ def test_create_server_config_no_server_dir( # Mock the necessary variables/functions to get us to the get_config_dir call mocker.patch("merlin.server.server_config.MERLIN_CONFIG_DIR", server_testing_dir) mocker.patch("merlin.server.server_config.write_container_command_files", return_value=True) - mock_open_func = mocker.mock_open(read_data='key: value') + mock_open_func = mocker.mock_open(read_data="key: value") mocker.patch("builtins.open", mock_open_func) mocker.patch("merlin.server.server_config.pull_server_config", return_value=ServerConfig(server_server_config)) @@ -380,7 +380,7 @@ def test_config_merlin_server_pass_user_dont_exist( def setup_pull_server_config_mock( - mocker: "Fixture", + mocker: "Fixture", # noqa: F821 server_testing_dir: str, server_app_yaml_contents: Dict[str, Union[str, int]], server_server_config: Dict[str, Dict[str, str]], @@ -394,7 +394,7 @@ def setup_pull_server_config_mock( :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class """ mocker.patch("merlin.server.server_util.AppYaml.get_data", return_value=server_app_yaml_contents) - mocker.patch('merlin.server.server_config.MERLIN_CONFIG_DIR', server_testing_dir) + mocker.patch("merlin.server.server_config.MERLIN_CONFIG_DIR", server_testing_dir) mock_data = mocker.mock_open(read_data=str(server_server_config)) mocker.patch("builtins.open", mock_data) @@ -404,8 +404,8 @@ def setup_pull_server_config_mock( [ ("container", 'Unable to find "container" object in {default_app_yaml}'), ("container.format", 'Unable to find "format" in {default_app_yaml}'), - ("process", 'Process config not found in {default_app_yaml}'), - ] + ("process", "Process config not found in {default_app_yaml}"), + ], ) def test_pull_server_config_missing_config_keys( mocker: "Fixture", # noqa: F821 @@ -429,7 +429,7 @@ def test_pull_server_config_missing_config_keys( :param expected_log_message: The expected log message when the key is missing """ # Handle nested key deletion - keys = key_to_delete.split('.') + keys = key_to_delete.split(".") temp_app_yaml = server_app_yaml_contents for key in keys[:-1]: temp_app_yaml = temp_app_yaml[key] @@ -545,14 +545,13 @@ def setup_pull_server_image_mock( image_file: str, create_config_file: bool = False, create_image_file: bool = False, - ): """ Set up the necessary mock calls for the `pull_server_image` function. :param mocker: A built-in fixture from the pytest-mock library to create a Mock object :param server_testing_dir: The path to the the temp output directory for server tests - :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class + :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class """ image_url = "docker://redis" image_path = f"{server_testing_dir}/{image_file}" @@ -567,7 +566,7 @@ def setup_pull_server_image_mock( os.mkdir(config_dir) with open(os.path.join(config_dir, config_file), "w"): pass - + if create_image_file: with open(image_path, "w"): pass @@ -585,20 +584,13 @@ def test_pull_server_image_no_image_path_no_config_path( :param mocker: A built-in fixture from the pytest-mock library to create a Mock object :param server_testing_dir: The path to the the temp output directory for server tests - :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class + :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class """ # Set up mock calls to simulate the setup of this function config_dir = f"{server_testing_dir}/config_dir" config_file = "pull_server_image_no_image_path_no_config_path_config_nonexistent.yaml" image_file = "pull_server_image_no_image_path_no_config_path_image_nonexistent.sif" - setup_pull_server_image_mock( - mocker, - server_testing_dir, - server_server_config, - config_dir, - config_file, - image_file - ) + setup_pull_server_image_mock(mocker, server_testing_dir, server_server_config, config_dir, config_file, image_file) mocked_subprocess = mocker.patch("subprocess.run") # Mock the open function @@ -635,7 +627,7 @@ def test_pull_server_image_both_paths_exist( :param mocker: A built-in fixture from the pytest-mock library to create a Mock object :param caplog: A built-in fixture from the pytest library to capture logs :param server_testing_dir: The path to the the temp output directory for server tests - :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class + :param server_server_config: A pytest fixture of test data to pass to the ServerConfig class """ caplog.set_level(logging.INFO) @@ -660,7 +652,7 @@ def test_pull_server_image_both_paths_exist( def test_pull_server_image_os_error( - mocker: "Fixture", + mocker: "Fixture", # noqa: F821 caplog: "Fixture", # noqa: F821 server_testing_dir: str, server_server_config: Dict[str, Dict[str, str]], @@ -697,12 +689,15 @@ def test_pull_server_image_os_error( assert f"Destination location {config_dir} is not writable." in caplog.text -@pytest.mark.parametrize("server_config_exists, config_exists, image_exists, pfile_exists, expected_status", [ - (False, True, True, True, ServerStatus.NOT_INITIALIZED), # No server config - (True, False, True, True, ServerStatus.NOT_INITIALIZED), # Config dir does not exist - (True, True, False, True, ServerStatus.MISSING_CONTAINER), # Image path does not exist - (True, True, True, False, ServerStatus.NOT_RUNNING), # Pfile path does not exist -]) +@pytest.mark.parametrize( + "server_config_exists, config_exists, image_exists, pfile_exists, expected_status", + [ + (False, True, True, True, ServerStatus.NOT_INITIALIZED), # No server config + (True, False, True, True, ServerStatus.NOT_INITIALIZED), # Config dir does not exist + (True, True, False, True, ServerStatus.MISSING_CONTAINER), # Image path does not exist + (True, True, True, False, ServerStatus.NOT_RUNNING), # Pfile path does not exist + ], +) def test_get_server_status_initial_checks( mocker: "Fixture", # noqa: F821 server_server_config: Dict[str, Dict[str, str]], @@ -736,11 +731,12 @@ def test_get_server_status_initial_checks( mocker.patch("merlin.server.server_util.ContainerConfig.get_pfile_path", return_value="pfile_path") # Mock os.path.exists to return the desired values - mocker.patch("os.path.exists", side_effect=lambda path: { - "config_dir": config_exists, - "image_path": image_exists, - "pfile_path": pfile_exists - }.get(path, False)) + mocker.patch( + "os.path.exists", + side_effect=lambda path: {"config_dir": config_exists, "image_path": image_exists, "pfile_path": pfile_exists}.get( + path, False + ), + ) else: mocker.patch("merlin.server.server_config.pull_server_config", return_value=None) @@ -748,10 +744,13 @@ def test_get_server_status_initial_checks( assert get_server_status() == expected_status -@pytest.mark.parametrize("stdout_val, expected_status", [ - (b"", ServerStatus.NOT_RUNNING), # No stdout from subprocess - (b"Successfully started", ServerStatus.RUNNING), # Stdout from subprocess exists -]) +@pytest.mark.parametrize( + "stdout_val, expected_status", + [ + (b"", ServerStatus.NOT_RUNNING), # No stdout from subprocess + (b"Successfully started", ServerStatus.RUNNING), # Stdout from subprocess exists + ], +) def test_get_server_status_subprocess_check( mocker: "Fixture", # noqa: F821 server_server_config: Dict[str, Dict[str, str]], @@ -774,13 +773,16 @@ def test_get_server_status_subprocess_check( assert get_server_status() == expected_status -@pytest.mark.parametrize("data_to_test, expected_result", [ - ({"image_pid": 123, "port": 6379, "hostname": "dummy_server"}, False), # No parent_pid entry - ({"parent_pid": 123, "port": 6379, "hostname": "dummy_server"}, False), # No image_pid entry - ({"parent_pid": 123, "image_pid": 456, "hostname": "dummy_server"}, False), # No port entry - ({"parent_pid": 123, "image_pid": 123, "port": 6379}, False), # No hostname entry - ({"parent_pid": 123, "image_pid": 123, "port": 6379, "hostname": "dummy_server"}, True), # All required entries exist -]) +@pytest.mark.parametrize( + "data_to_test, expected_result", + [ + ({"image_pid": 123, "port": 6379, "hostname": "dummy_server"}, False), # No parent_pid entry + ({"parent_pid": 123, "port": 6379, "hostname": "dummy_server"}, False), # No image_pid entry + ({"parent_pid": 123, "image_pid": 456, "hostname": "dummy_server"}, False), # No port entry + ({"parent_pid": 123, "image_pid": 123, "port": 6379}, False), # No hostname entry + ({"parent_pid": 123, "image_pid": 123, "port": 6379, "hostname": "dummy_server"}, True), # All required entries exist + ], +) def test_check_process_file_format(data_to_test: Dict[str, Union[int, str]], expected_result: bool): """ Test the `check_process_file_format` function. The first 4 parametrized tests above should all @@ -803,8 +805,8 @@ def test_pull_process_file_valid_file(server_testing_dir: str, server_process_fi """ # Create the valid process file in our temp testing directory process_filepath = f"{server_testing_dir}/valid_process_file.yaml" - with open(process_filepath, 'w') as process_file: - yaml.dump(server_process_file_contents, process_file) + with open(process_filepath, "w") as process_file: + yaml.dump(server_process_file_contents, process_file) # Run the test assert pull_process_file(process_filepath) == server_process_file_contents @@ -824,8 +826,8 @@ def test_pull_process_file_invalid_file(server_testing_dir: str, server_process_ # Create the invalid process file in our temp testing directory process_filepath = f"{server_testing_dir}/invalid_process_file.yaml" - with open(process_filepath, 'w') as process_file: - yaml.dump(server_process_file_contents, process_file) + with open(process_filepath, "w") as process_file: + yaml.dump(server_process_file_contents, process_file) # Run the test assert pull_process_file(process_filepath) is None