File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed
Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change 1- """Test the converter.
2-
3- This test script generates data for the image converter functions
4- to be used in the main test suite.
5- """
1+ """Test the configuration file handling."""
62
73from pathlib import Path
84from unittest .mock import MagicMock , patch
@@ -91,3 +87,27 @@ def test_get_connection_malformed_value(tmp_path: Path) -> None:
9187
9288 with pytest .raises (ValueError ):
9389 get_connection_from_config (str (config_file ))
90+
91+
92+ @patch ("odoo_data_flow.lib.conf_lib.odoolib.get_connection" )
93+ def test_get_connection_generic_exception (
94+ mock_get_connection : MagicMock , tmp_path : Path
95+ ) -> None :
96+ """Tests that a generic Exception during connection is caught and re-raised."""
97+ # 1. Setup: Create a valid config file
98+ config_file = tmp_path / "connection.conf"
99+ config_content = """
100+ [Connection]
101+ hostname = test-server
102+ database = test-db
103+ login = test-user
104+ password = test-pass
105+ """
106+ config_file .write_text (config_content )
107+
108+ # Configure the mock to raise a generic exception
109+ mock_get_connection .side_effect = Exception ("A generic connection error occurred" )
110+
111+ # 2. Action & Assertions
112+ with pytest .raises (Exception , match = "A generic connection error occurred" ):
113+ get_connection_from_config (str (config_file ))
You can’t perform that action at this time.
0 commit comments