Update unit tests

This commit is contained in:
Oliver Walters 2020-11-12 14:48:57 +11:00
parent ec8d8e5a64
commit 1738df9042
2 changed files with 22 additions and 14 deletions

View File

@ -4,20 +4,7 @@ from __future__ import unicode_literals
from django.test import TestCase
from django.contrib.auth import get_user_model
from .models import Currency, InvenTreeSetting
class CurrencyTest(TestCase):
""" Tests for Currency model """
fixtures = [
'currency',
]
def test_currency(self):
# Simple test for now (improve this later!)
self.assertEqual(Currency.objects.count(), 2)
from .models import InvenTreeSetting
class SettingsTest(TestCase):
@ -25,6 +12,10 @@ class SettingsTest(TestCase):
Tests for the 'settings' model
"""
fixtures = [
'settings',
]
def setUp(self):
User = get_user_model()
@ -35,6 +26,20 @@ class SettingsTest(TestCase):
self.client.login(username='username', password='password')
def test_settings_objects(self):
# There should be two settings objects in the database
settings = InvenTreeSetting.objects.all()
self.assertEqual(settings.count(), 2)
instance_name = InvenTreeSetting.objects.get(pk=1)
self.assertEqual(instance_name.key, 'INVENTREE_INSTANCE')
self.assertEqual(instance_name.value, 'My very first InvenTree Instance')
self.assertEqual(InvenTreeSetting.get_setting_object('iNvEnTrEE_inSTanCE').pk, 21)
def test_required_values(self):
"""
- Ensure that every global setting has a name.

View File

@ -300,6 +300,9 @@ def import_fixtures(c):
# Build model
'build',
# Common models
'settings',
# Company model
'company',
'price_breaks',