2017-11-11 22:25:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-12-06 17:01:45 +00:00
|
|
|
from django.test import TransactionTestCase
|
2022-10-20 18:54:24 +00:00
|
|
|
from django.contrib.auth.models import User, Group
|
2017-11-11 22:25:28 +00:00
|
|
|
from django.core.management import call_command
|
|
|
|
|
|
|
|
from core.models import Child
|
|
|
|
|
|
|
|
|
2017-12-06 17:01:45 +00:00
|
|
|
class CommandsTestCase(TransactionTestCase):
|
2017-11-11 22:25:28 +00:00
|
|
|
def test_migrate(self):
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("migrate", verbosity=0)
|
|
|
|
self.assertIsInstance(User.objects.get(username="admin"), User)
|
2017-11-11 22:25:28 +00:00
|
|
|
|
|
|
|
def test_fake(self):
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("migrate", verbosity=0)
|
|
|
|
call_command("fake", children=1, days=7, verbosity=0)
|
2017-11-11 22:25:28 +00:00
|
|
|
self.assertEqual(Child.objects.count(), 1)
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("fake", children=2, days=7, verbosity=0)
|
2017-11-11 22:25:28 +00:00
|
|
|
self.assertEqual(Child.objects.count(), 3)
|
|
|
|
|
2017-12-06 17:01:45 +00:00
|
|
|
def test_reset(self):
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("reset", verbosity=0, interactive=False)
|
|
|
|
self.assertIsInstance(User.objects.get(username="admin"), User)
|
2017-12-06 17:01:45 +00:00
|
|
|
self.assertEqual(Child.objects.count(), 1)
|
2022-10-04 15:24:01 +00:00
|
|
|
|
|
|
|
def test_createuser(self):
|
|
|
|
call_command(
|
|
|
|
"createuser",
|
|
|
|
username="test",
|
|
|
|
email="test@test.test",
|
|
|
|
password="test",
|
|
|
|
verbosity=0,
|
|
|
|
)
|
|
|
|
self.assertIsInstance(User.objects.get(username="test"), User)
|
2022-10-22 06:15:49 +00:00
|
|
|
self.assertFalse(
|
|
|
|
User.objects.filter(username="test", is_staff=True, is_superuser=True)
|
|
|
|
)
|
2022-10-04 15:24:01 +00:00
|
|
|
call_command(
|
|
|
|
"createuser",
|
2022-10-22 06:15:49 +00:00
|
|
|
"--is-staff",
|
2022-10-04 15:24:01 +00:00
|
|
|
username="testadmin",
|
|
|
|
email="testadmin@testadmin.testadmin",
|
|
|
|
password="test",
|
|
|
|
verbosity=0,
|
|
|
|
)
|
|
|
|
self.assertIsInstance(User.objects.get(username="testadmin"), User)
|
2022-10-22 06:15:49 +00:00
|
|
|
self.assertTrue(
|
|
|
|
User.objects.filter(username="testadmin", is_staff=True, is_superuser=True)
|
|
|
|
)
|