mybuddy/babybuddy/tests/tests_models.py

30 lines
906 B
Python
Raw Normal View History

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