from django.contrib.auth.models import Group from django.core.management import call_command from django.test import TestCase from apps.accounts.models import User class AdminSmokeTests(TestCase): def setUp(self): self.admin = User.objects.create_superuser( phone="+79990000000", password="admin12345" ) self.client.force_login(self.admin) def test_admin_index_renders_dashboard(self): response = self.client.get("/admin/") self.assertEqual(response.status_code, 200) self.assertContains(response, "Сводка") def test_admin_changelists(self): urls = [ "/admin/orders/order/", "/admin/catalog/product/", "/admin/accounts/user/", "/admin/loyalty/promocode/", "/admin/integration/syncrun/", "/admin/integration/outboxmessage/", "/admin/content/sitesettings/", "/admin/content/staticpage/", "/admin/content/banner/", "/admin/admin/logentry/", ] for url in urls: with self.subTest(url=url): self.assertEqual(self.client.get(url).status_code, 200) class RolesCommandTests(TestCase): def test_create_roles(self): call_command("create_roles") self.assertTrue(Group.objects.filter(name="Контент-менеджер").exists()) self.assertTrue(Group.objects.filter(name="Менеджер заказов").exists()) self.assertTrue(Group.objects.filter(name="Менеджер лояльности").exists()) self.assertTrue(Group.objects.filter(name="Технический администратор").exists())