From 27e90c24cd8fe62de1f1694479b59993ccc538e9 Mon Sep 17 00:00:00 2001 From: ievgenii vdovenko Date: Wed, 16 Jul 2025 13:33:26 +0200 Subject: [PATCH] tests: adds fail test --- .../authentication/tests/services/test_ldap_dao.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rhodecode/authentication/tests/services/test_ldap_dao.py b/rhodecode/authentication/tests/services/test_ldap_dao.py index 1de4bf42..cceb9f6f 100644 --- a/rhodecode/authentication/tests/services/test_ldap_dao.py +++ b/rhodecode/authentication/tests/services/test_ldap_dao.py @@ -39,3 +39,14 @@ class TestLdapDao(unittest.TestCase): self.ldap_dao.fetch_all() conn.unbind_s.assert_called_once() + + @patch.object(LdapDao, "_get_ldap_conn") + def test_fetch_all_release_connection_on_error(self, _get_ldap_conn_mock, ldap_mock): + conn = MagicMock() + _get_ldap_conn_mock.return_value = conn + conn.search_ext_s.side_effect = Exception("Test exception") + + res = self.ldap_dao.fetch_all() + + assert res is None + conn.unbind_s.assert_called_once()