2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00
Files
InvenTree/InvenTree/users/test_migrations.py
Oliver 4785f465e8 Cleanup / consolidate unit testing code ()
- Move testing code out of helpers.py
- Create new file unit_test.py
2023-05-17 07:35:26 +10:00

35 lines
1.0 KiB
Python

"""Unit tests for the user model database migrations."""
from django_test_migrations.contrib.unittest_case import MigratorTestCase
from InvenTree import unit_test
class TestForwardMigrations(MigratorTestCase):
"""Test entire schema migration sequence for the users app."""
migrate_from = ('users', unit_test.getOldestMigrationFile('users'))
migrate_to = ('users', unit_test.getNewestMigrationFile('users'))
def prepare(self):
"""Setup the initial state of the database before migrations"""
User = self.old_state.apps.get_model('auth', 'user')
User.objects.create(
username='fred',
email='fred@fred.com',
password='password'
)
User.objects.create(
username='brad',
email='brad@fred.com',
password='password'
)
def test_users_exist(self):
"""Test that users exist in the database"""
User = self.new_state.apps.get_model('auth', 'user')
self.assertEqual(User.objects.count(), 2)