2017-11-13 00:43:40 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-02-06 14:59:57 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
2017-11-13 00:43:40 +00:00
|
|
|
from django.core.management import call_command
|
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
from babybuddy.models import Settings
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsTestCase(TestCase):
|
|
|
|
def setUp(self):
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("migrate", verbosity=0)
|
2017-11-13 00:43:40 +00:00
|
|
|
|
|
|
|
def test_settings(self):
|
2022-02-10 00:00:30 +00:00
|
|
|
credentials = {"username": "Test", "password": "User"}
|
2023-02-06 14:59:57 +00:00
|
|
|
user = get_user_model().objects.create_user(is_superuser=True, **credentials)
|
2017-11-13 00:43:40 +00:00
|
|
|
self.assertIsInstance(user.settings, Settings)
|
2022-02-10 00:00:30 +00:00
|
|
|
self.assertEqual(user.settings.dashboard_refresh_rate_milliseconds, 60000)
|
2017-11-13 00:43:40 +00:00
|
|
|
|
|
|
|
user.settings.dashboard_refresh_rate = None
|
|
|
|
user.save()
|
|
|
|
self.assertIsNone(user.settings.dashboard_refresh_rate_milliseconds)
|
2019-04-19 02:52:17 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
user.settings.language = "fr"
|
2019-04-19 02:52:17 +00:00
|
|
|
user.save()
|
2022-02-10 00:00:30 +00:00
|
|
|
self.assertEqual(user.settings.language, "fr")
|