Skip to content

Commit

Permalink
Apply Black formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
glrs committed Oct 4, 2024
1 parent 1c8a72b commit 982e6e7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_config_loader.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import types
import unittest
from unittest.mock import patch, mock_open
from lib.core_utils.config_loader import ConfigLoader
from pathlib import Path
import types
from unittest.mock import mock_open, patch

from lib.core_utils.config_loader import ConfigLoader


class TestConfigLoader(unittest.TestCase):

def setUp(self):
self.config_loader = ConfigLoader()

@patch('lib.utils.config_loader.Ygg.get_path', return_value=Path('dummy_file_path'))
@patch('builtins.open', new_callable=mock_open, read_data='{"key": "value"}')
@patch('json.load', return_value={"key": "value"})
@patch("lib.utils.config_loader.Ygg.get_path", return_value=Path("dummy_file_path"))
@patch("builtins.open", new_callable=mock_open, read_data='{"key": "value"}')
@patch("json.load", return_value={"key": "value"})
def test_load_config(self, mock_json_load, mock_file, mock_get_path):
# Create an instance of the ConfigLoader class
config_loader = ConfigLoader()
# Call the load_config method
config = config_loader.load_config('dummy_file_name')
config = config_loader.load_config("dummy_file_name")
# Assert the Ygg.get_path function was called
mock_get_path.assert_called_once_with('dummy_file_name')
mock_get_path.assert_called_once_with("dummy_file_name")
# Assert the file was opened
mock_file.assert_called_once_with(Path('dummy_file_path'), 'r')
mock_file.assert_called_once_with(Path("dummy_file_path"), "r")
# Assert the json.load function was called
mock_json_load.assert_called_once()
# Assert the config was loaded correctly
self.assertEqual(config, types.MappingProxyType({"key": "value"}))


@patch('builtins.open', new_callable=mock_open, read_data='{"key": "value"}')
@patch('json.load', return_value={"key": "value"})
@patch("builtins.open", new_callable=mock_open, read_data='{"key": "value"}')
@patch("json.load", return_value={"key": "value"})
def test_load_config_path(self, mock_json_load, mock_file):
# Call the load_config_path method
config = self.config_loader.load_config_path('/path/to/config.json')
config = self.config_loader.load_config_path("/path/to/config.json")
# Assert the file was opened
mock_file.assert_called_once_with(Path('/path/to/config.json'), 'r')
mock_file.assert_called_once_with(Path("/path/to/config.json"), "r")
# Assert the json.load function was called
mock_json_load.assert_called_once()
# Assert the config was loaded correctly
self.assertEqual(config, types.MappingProxyType({"key": "value"}))

def test_getitem(self):
def test_getitem2(self):
# Load some configuration data
self.config_loader._config = types.MappingProxyType({"key": "value"})
# Call the __getitem__ method
Expand Down

0 comments on commit 982e6e7

Please sign in to comment.