""" Unit тесты для моделей уведомлений. """ import pytest from apps.notifications.models import Notification, NotificationPreference @pytest.mark.django_db @pytest.mark.unit class TestNotificationModel: """Тесты модели Notification.""" def test_create_notification(self, mentor_user): """Тест создания уведомления.""" notification = Notification.objects.create( user=mentor_user, title='Новое сообщение', message='У вас новое сообщение', notification_type='info' ) assert notification.user == mentor_user assert notification.title == 'Новое сообщение' assert notification.is_read is False def test_mark_as_read(self, mentor_user): """Тест отметки уведомления как прочитанного.""" notification = Notification.objects.create( user=mentor_user, title='Тест', message='Сообщение', notification_type='info' ) notification.mark_as_read() assert notification.is_read is True assert notification.read_at is not None @pytest.mark.django_db @pytest.mark.unit class TestNotificationPreferenceModel: """Тесты модели NotificationPreference.""" def test_create_preference(self, mentor_user): """Тест создания настроек уведомлений.""" preference = NotificationPreference.objects.create( user=mentor_user, email_enabled=True, telegram_enabled=False, push_enabled=True ) assert preference.user == mentor_user assert preference.email_enabled is True assert preference.telegram_enabled is False assert preference.push_enabled is True