test: fix tests after views split
- Remove @pytest.fixture from make_user (it's a helper function, not a fixture) - Update _is_ldap_enabled patch paths to api.v1.employees.views._helpers - Fixes AttributeError and fixture calling errors
This commit is contained in:
parent
f85b5dfa08
commit
3977c99c0c
@ -18,7 +18,7 @@ Employee = get_user_model()
|
||||
@pytest.fixture(autouse=True)
|
||||
def disable_ldap():
|
||||
"""Отключает LDAP для всех тестов."""
|
||||
with patch("api.v1.employees.views._is_ldap_enabled", return_value=False):
|
||||
with patch("api.v1.employees.views._helpers._is_ldap_enabled", return_value=False):
|
||||
yield
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -217,7 +217,7 @@ def test_delete_requires_perm_or_staff(api_client):
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_syncs_to_ldap_if_has_dn(
|
||||
mock_update, mock_is_enabled, api_client
|
||||
@ -262,7 +262,7 @@ def test_dismissal_syncs_to_ldap_if_has_dn(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_handles_ldap_error_gracefully(
|
||||
mock_update, mock_is_enabled, api_client
|
||||
@ -308,7 +308,7 @@ def test_dismissal_handles_ldap_error_gracefully(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_non_dismissal_syncs_activation_to_ldap(
|
||||
mock_update, mock_is_enabled, api_client
|
||||
@ -355,7 +355,7 @@ def test_non_dismissal_syncs_activation_to_ldap(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_skips_ldap_if_no_dn(
|
||||
mock_update, mock_is_enabled, api_client
|
||||
@ -388,7 +388,7 @@ def test_dismissal_skips_ldap_if_no_dn(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_works_when_ldap_disabled(
|
||||
mock_update, mock_is_enabled, api_client
|
||||
@ -431,7 +431,7 @@ def test_dismissal_works_when_ldap_disabled(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.remove_member')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_moves_to_dismissed_ou(
|
||||
@ -491,7 +491,7 @@ def test_dismissal_moves_to_dismissed_ou(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.infrastructure.connections._ldap')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_restoration_moves_from_dismissed_to_users(
|
||||
@ -550,7 +550,7 @@ def test_restoration_moves_from_dismissed_to_users(
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch('api.v1.employees.views._is_ldap_enabled')
|
||||
@patch('api.v1.employees.views._helpers._is_ldap_enabled')
|
||||
@patch('employees.ldap.infrastructure.connections._ldap')
|
||||
@patch('employees.ldap.directory_service.DirectoryService.update_user')
|
||||
def test_dismissal_without_department_moves_to_dismissed(
|
||||
|
||||
@ -35,7 +35,6 @@ def _unique_phone() -> str:
|
||||
# валидный уникальный E.164
|
||||
return f"+7999000{next(_phone_seq):03d}"
|
||||
|
||||
@pytest.fixture
|
||||
def make_user(
|
||||
email: str,
|
||||
*,
|
||||
@ -45,7 +44,7 @@ def make_user(
|
||||
active: bool = True,
|
||||
**extra,
|
||||
) -> User:
|
||||
"""Fixture для создания пользователей."""
|
||||
"""Helper для создания пользователей в тестах."""
|
||||
"""
|
||||
Создаём пользователя напрямую (без менеджера, чтобы не слать почту).
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user