1111 AllowlistPackageDoesNotExistError ,
1212 TOMLError ,
1313)
14+ from twyn .file_handler .exceptions import PathNotFoundError
1415
1516
1617class TestConfig :
1718 def throw_exception (self ):
18- raise FileNotFoundError
19+ raise PathNotFoundError
1920
20- @patch ("twyn.config.config_handler.ConfigHandler._get_toml_file_pointer " )
21+ @patch ("twyn.file_handler.file_handler.FileHandlerPathlib.read " )
2122 def test_enforce_file_error (self , mock_is_file ):
2223 mock_is_file .side_effect = self .throw_exception
2324 with pytest .raises (TOMLError ):
2425 ConfigHandler (enforce_file = True ).resolve_config ()
2526
26- @patch ("twyn.config.config_handler.ConfigHandler._get_toml_file_pointer " )
27+ @patch ("twyn.file_handler.file_handler.FileHandlerPathlib.read " )
2728 def test_no_enforce_file_on_non_existent_file (self , mock_is_file ):
2829 """Resolving the config without enforcing the file to be present gives you defaults."""
2930 mock_is_file .side_effect = self .throw_exception
@@ -42,17 +43,17 @@ def test_config_raises_for_unknown_file(self):
4243 ConfigHandler (file_path = "non-existent-file.toml" ).resolve_config ()
4344
4445 def test_read_config_values (self , pyproject_toml_file ):
45- config = ConfigHandler (file_path = pyproject_toml_file ).resolve_config ()
46+ config = ConfigHandler (file_path = str ( pyproject_toml_file ) ).resolve_config ()
4647 assert config .dependency_file == "my_file.txt"
4748 assert config .selector_method == "my_selector"
4849 assert config .logging_level == AvailableLoggingLevels .debug
4950 assert config .allowlist == {"boto4" , "boto2" }
5051
5152 def test_get_twyn_data_from_file (self , pyproject_toml_file ):
52- handler = ConfigHandler (file_path = pyproject_toml_file )
53+ handler = ConfigHandler (str ( pyproject_toml_file ) )
5354
5455 toml = handler ._read_toml ()
55- twyn_data = ConfigHandler (file_path = pyproject_toml_file )._get_read_config (toml )
56+ twyn_data = ConfigHandler (pyproject_toml_file )._get_read_config (toml )
5657 assert twyn_data == ReadTwynConfiguration (
5758 dependency_file = "my_file.txt" ,
5859 selector_method = "my_selector" ,
@@ -62,7 +63,7 @@ def test_get_twyn_data_from_file(self, pyproject_toml_file):
6263 )
6364
6465 def test_write_toml (self , pyproject_toml_file ):
65- handler = ConfigHandler (file_path = pyproject_toml_file )
66+ handler = ConfigHandler (pyproject_toml_file )
6667 toml = handler ._read_toml ()
6768
6869 initial_config = handler .resolve_config ()
@@ -103,12 +104,12 @@ def test_write_toml(self, pyproject_toml_file):
103104
104105
105106class TestAllowlistConfigHandler :
106- @patch ("twyn.config.config_handler.ConfigHandler._write_toml " )
107+ @patch ("twyn.file_handler.file_handler.FileHandlerPathlib.write " )
107108 @patch ("twyn.config.config_handler.ConfigHandler._read_toml" )
108109 def test_allowlist_add (self , mock_toml , mock_write_toml ):
109110 mock_toml .return_value = TOMLDocument ()
110111
111- config = ConfigHandler ()
112+ config = ConfigHandler ("some-file" )
112113
113114 config .add_package_to_allowlist ("mypackage" )
114115
0 commit comments