Skip to content

Admin

ReminderAdmin

Bases: ModelAdmin

Admin page for Reminder model

Models

Reminder

Bases: Model

Reminder notification model

Test Case

TestApiView

Bases: TestCase

Test all api view

test_get_reminder_api

test_get_reminder_api()

Test reminder api

Source code in django_project/notification/tests/test_api_views.py
@override_settings(DISABLE_2FA=True)
def test_get_reminder_api(self):
    """Test reminder api"""
    ReminderF.create(
        id=1,
        title='Title test 1',
        text='Reminder text 1',
        status='active',
    )

    self.client.login(username=self.user.username, password='password')

    pk = '1'
    api_url = '/api/reminder/?reminderId=' + pk
    response = self.client.get(api_url)

    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertTrue('id' in response.data)

test_list_reminders_api

test_list_reminders_api()

Test reminder aip

Source code in django_project/notification/tests/test_api_views.py
@override_settings(DISABLE_2FA=True)
def test_list_reminders_api(self):
    """Test reminder aip"""
    ReminderF.create(
        id=1,
        title='Title test 1',
        text='Reminder text 1',
        status='active',
    )
    ReminderF.create(
        title='Title test 2',
        text='Reminder text 2',
        status='active',
    )

    self.client.login(username=self.user.username, password='password')

    reminder_status = 'active'
    api_url = '/api/reminders/?status=' + reminder_status
    response = self.client.get(api_url)

    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEqual(len(response.data), 2)

TestReminder

Bases: TestCase

Test for Reminder model

setUp

setUp()

setup test data

Source code in django_project/notification/tests/test_reminder.py
def setUp(self) -> None:
    """setup test data"""
    self.reminder = ReminderF(title='title0', text='text0')

test_create_reminder

test_create_reminder()

test create reminder

Source code in django_project/notification/tests/test_reminder.py
def test_create_reminder(self):
    """test create reminder"""
    self.assertEqual(self.reminder.title, 'title0')
    self.assertEqual(self.reminder.text, 'text0')
    self.assertEqual(Reminder.objects.count(), 1)

test_delete_reminder

test_delete_reminder()

test delete reminder

Source code in django_project/notification/tests/test_reminder.py
def test_delete_reminder(self):
    """test delete reminder"""
    self.reminder.delete()
    self.assertEqual(Reminder.objects.count(), 0)

test_update_reminder

test_update_reminder()

test update reminder

Source code in django_project/notification/tests/test_reminder.py
def test_update_reminder(self):
    """test update reminder"""
    self.reminder.title = 'Test title'
    self.reminder.status = 'draft'
    self.reminder.save()
    self.assertEqual(self.reminder.title, 'Test title')
    self.assertEqual(self.reminder.status, 'draft')