Implement exchange imports and frontend reporting APIs
Some checks failed
CI/CD Pipeline / Code Quality Checks (push) Failing after 3m50s
CI/CD Pipeline / Run Tests (push) Successful in 3m57s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
Some checks failed
CI/CD Pipeline / Code Quality Checks (push) Failing after 3m50s
CI/CD Pipeline / Run Tests (push) Successful in 3m57s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
"""Тесты для BackgroundJob."""
|
||||
|
||||
from django.test import TestCase
|
||||
from faker import Faker
|
||||
|
||||
from apps.core.models import BackgroundJob, JobStatus
|
||||
from apps.core.services import BackgroundJobService
|
||||
from django.test import TestCase
|
||||
from faker import Faker
|
||||
|
||||
fake = Faker()
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
"""Тесты для BulkOperationsMixin и QueryOptimizerMixin."""
|
||||
|
||||
from django.test import TestCase
|
||||
from faker import Faker
|
||||
|
||||
from apps.core.models import BackgroundJob
|
||||
from apps.core.services import (
|
||||
BulkOperationsMixin,
|
||||
QueryOptimizerMixin,
|
||||
)
|
||||
from django.test import TestCase
|
||||
from faker import Faker
|
||||
|
||||
fake = Faker()
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
"""Tests for core cache utilities"""
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.cache import (
|
||||
CacheManager,
|
||||
_build_cache_key,
|
||||
cache_method,
|
||||
cache_result,
|
||||
)
|
||||
from django.core.cache import cache
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class CacheResultDecoratorTest(TestCase):
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.excel import (
|
||||
BaseExcelParser,
|
||||
ColumnMapping,
|
||||
@@ -14,7 +16,6 @@ from apps.core.excel import (
|
||||
validate_ogrn,
|
||||
validate_okpo,
|
||||
)
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class ValidatorsTest(TestCase):
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Tests for core exceptions and exception handler"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.exceptions import (
|
||||
AuthenticationError,
|
||||
BadRequestError,
|
||||
@@ -16,7 +18,6 @@ from apps.core.exceptions import (
|
||||
ServiceUnavailableError,
|
||||
ValidationError,
|
||||
)
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class BaseAPIExceptionTest(TestCase):
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"""Tests for core filter utilities"""
|
||||
|
||||
from django.test import TestCase
|
||||
from django_filters import rest_framework as filters
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
|
||||
from apps.core.filters import (
|
||||
BaseFilterSet,
|
||||
FilterMixin,
|
||||
@@ -7,9 +11,6 @@ from apps.core.filters import (
|
||||
StandardSearchFilter,
|
||||
get_filter_backends,
|
||||
)
|
||||
from django.test import TestCase
|
||||
from django_filters import rest_framework as filters
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
|
||||
|
||||
class BaseFilterSetTest(TestCase):
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
from io import StringIO
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.external_data.models import (
|
||||
ArbitrationCase,
|
||||
IndustrialProduct,
|
||||
ProsecutorCheck,
|
||||
PublicProcurement,
|
||||
)
|
||||
from apps.form_1.models import FormF1Record
|
||||
from apps.form_2.models import FormF2Record
|
||||
from apps.form_3.models import FormF3Record
|
||||
@@ -10,8 +19,6 @@ from apps.form_5.models import FormF5Record
|
||||
from apps.form_6.models import FormF6Record
|
||||
from apps.organization.models import Organization
|
||||
from apps.registers.models import RegisterUpload, RegistryMembershipPeriod
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class GenerateTestReportsCommandTest(TestCase):
|
||||
@@ -28,7 +35,9 @@ class GenerateTestReportsCommandTest(TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
Organization.objects.filter(name__startswith="Автотест организация").count(),
|
||||
Organization.objects.filter(
|
||||
name__startswith="Автотест организация"
|
||||
).count(),
|
||||
3,
|
||||
)
|
||||
self.assertEqual(FormF1Record.objects.count(), 12)
|
||||
@@ -38,16 +47,74 @@ class GenerateTestReportsCommandTest(TestCase):
|
||||
self.assertEqual(FormF5Record.objects.count(), 12)
|
||||
self.assertEqual(FormF6Record.objects.count(), 12)
|
||||
self.assertEqual(FormF1Record.objects.filter(is_active_version=True).count(), 9)
|
||||
self.assertEqual(FormF1Record.objects.filter(is_active_version=False).count(), 3)
|
||||
self.assertEqual(
|
||||
FormF1Record.objects.filter(is_active_version=False).count(), 3
|
||||
)
|
||||
self.assertEqual(
|
||||
RegistryMembershipPeriod.objects.filter(ended_at__isnull=True).count(),
|
||||
3,
|
||||
)
|
||||
self.assertGreaterEqual(RegisterUpload.objects.count(), 1)
|
||||
self.assertEqual(IndustrialProduct.objects.count(), 3)
|
||||
self.assertEqual(ProsecutorCheck.objects.count(), 3)
|
||||
self.assertEqual(PublicProcurement.objects.count(), 3)
|
||||
self.assertEqual(ArbitrationCase.objects.count(), 3)
|
||||
|
||||
self.assertIn("Ф-1: создано 12 записей, активных 9, архивных 3", stdout.getvalue())
|
||||
self.assertIn("Ф-6: создано 12 записей, активных 9, архивных 3", stdout.getvalue())
|
||||
self.assertIn(
|
||||
"Ф-1: создано 12 записей, активных 9, архивных 3", stdout.getvalue()
|
||||
)
|
||||
self.assertIn(
|
||||
"Ф-6: создано 12 записей, активных 9, архивных 3", stdout.getvalue()
|
||||
)
|
||||
self.assertIn("Реестры: актуальных участий создано 3", stdout.getvalue())
|
||||
self.assertIn(
|
||||
"Внешние данные: products=3, checks=3, procurements=3, arbitration=3",
|
||||
stdout.getvalue(),
|
||||
)
|
||||
|
||||
def test_generate_test_reports_clears_previous_dataset_before_regeneration(self):
|
||||
call_command(
|
||||
"generate_test_reports",
|
||||
count=3,
|
||||
prefix="Первый прогон",
|
||||
)
|
||||
|
||||
stdout = StringIO()
|
||||
call_command(
|
||||
"generate_test_reports",
|
||||
count=2,
|
||||
prefix="Второй прогон",
|
||||
stdout=stdout,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
Organization.objects.filter(name__startswith="Второй прогон").count(),
|
||||
2,
|
||||
)
|
||||
self.assertFalse(
|
||||
Organization.objects.filter(name__startswith="Первый прогон").exists()
|
||||
)
|
||||
self.assertEqual(Organization.objects.count(), 2)
|
||||
self.assertEqual(FormF1Record.objects.count(), 8)
|
||||
self.assertEqual(FormF2Record.objects.count(), 8)
|
||||
self.assertEqual(FormF3Record.objects.count(), 8)
|
||||
self.assertEqual(FormF4Record.objects.count(), 8)
|
||||
self.assertEqual(FormF5Record.objects.count(), 8)
|
||||
self.assertEqual(FormF6Record.objects.count(), 8)
|
||||
self.assertEqual(FormF1Record.objects.filter(is_active_version=True).count(), 6)
|
||||
self.assertEqual(
|
||||
FormF1Record.objects.filter(is_active_version=False).count(), 2
|
||||
)
|
||||
self.assertEqual(
|
||||
RegistryMembershipPeriod.objects.filter(ended_at__isnull=True).count(),
|
||||
2,
|
||||
)
|
||||
self.assertEqual(IndustrialProduct.objects.count(), 2)
|
||||
self.assertEqual(ProsecutorCheck.objects.count(), 2)
|
||||
self.assertEqual(PublicProcurement.objects.count(), 2)
|
||||
self.assertEqual(ArbitrationCase.objects.count(), 2)
|
||||
|
||||
self.assertIn("Очистка старых данных: организаций 3", stdout.getvalue())
|
||||
|
||||
def test_generate_test_reports_dry_run_rolls_back_changes(self):
|
||||
stdout = StringIO()
|
||||
@@ -71,5 +138,9 @@ class GenerateTestReportsCommandTest(TestCase):
|
||||
self.assertEqual(FormF6Record.objects.count(), 0)
|
||||
self.assertEqual(RegisterUpload.objects.count(), 0)
|
||||
self.assertEqual(RegistryMembershipPeriod.objects.count(), 0)
|
||||
self.assertEqual(IndustrialProduct.objects.count(), 0)
|
||||
self.assertEqual(ProsecutorCheck.objects.count(), 0)
|
||||
self.assertEqual(PublicProcurement.objects.count(), 0)
|
||||
self.assertEqual(ArbitrationCase.objects.count(), 0)
|
||||
|
||||
self.assertIn("Dry-run: транзакция откачена", stdout.getvalue())
|
||||
|
||||
@@ -4,12 +4,13 @@ import json
|
||||
import logging
|
||||
from io import StringIO
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.logging import (
|
||||
ContextLogger,
|
||||
JSONFormatter,
|
||||
get_json_logging_config,
|
||||
)
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class JSONFormatterTest(TestCase):
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
from io import StringIO
|
||||
|
||||
from apps.core.management.commands.base import BaseAppCommand
|
||||
from django.core.management.base import CommandError
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.management.commands.base import BaseAppCommand
|
||||
|
||||
|
||||
class TestCommand(BaseAppCommand):
|
||||
"""Тестовая команда для проверки BaseAppCommand."""
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"""Тесты для Model Mixins."""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.mixins import (
|
||||
OrderableMixin,
|
||||
SoftDeleteMixin,
|
||||
StatusMixin,
|
||||
)
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class TimestampMixinTest(TestCase):
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"""Tests for core OpenAPI utilities"""
|
||||
|
||||
from django.test import TestCase
|
||||
from drf_yasg import openapi
|
||||
from rest_framework import serializers
|
||||
|
||||
from apps.core.openapi import (
|
||||
CommonParameters,
|
||||
CommonResponses,
|
||||
@@ -7,9 +11,6 @@ from apps.core.openapi import (
|
||||
api_docs,
|
||||
paginated_response,
|
||||
)
|
||||
from django.test import TestCase
|
||||
from drf_yasg import openapi
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class DummySerializer(serializers.Serializer):
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"""Tests for core permissions"""
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import RequestFactory, TestCase
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from apps.core.permissions import (
|
||||
IsAdmin,
|
||||
IsAdminOrReadOnly,
|
||||
@@ -9,10 +13,6 @@ from apps.core.permissions import (
|
||||
IsSuperuser,
|
||||
IsVerified,
|
||||
)
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import RequestFactory, TestCase
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from tests.apps.user.factories import UserFactory
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
"""Tests for core response wrapper"""
|
||||
|
||||
from django.test import TestCase
|
||||
from rest_framework import status
|
||||
|
||||
from apps.core.response import (
|
||||
api_created_response,
|
||||
api_error_response,
|
||||
@@ -7,8 +10,6 @@ from apps.core.response import (
|
||||
api_paginated_response,
|
||||
api_response,
|
||||
)
|
||||
from django.test import TestCase
|
||||
from rest_framework import status
|
||||
|
||||
|
||||
class APIResponseTest(TestCase):
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""Tests for core services"""
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.exceptions import NotFoundError
|
||||
from apps.core.services import BaseService
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
"""Tests for core signals utilities"""
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.signals import (
|
||||
SignalDispatcher,
|
||||
@@ -12,10 +15,6 @@ from apps.core.signals import (
|
||||
user_registered,
|
||||
user_verified,
|
||||
)
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
from django.test import TestCase
|
||||
|
||||
from tests.apps.user.factories import UserFactory
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Tests for core Celery tasks"""
|
||||
|
||||
from celery import Task
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.core.tasks import (
|
||||
BaseTask,
|
||||
@@ -8,8 +10,6 @@ from apps.core.tasks import (
|
||||
TimedTask,
|
||||
TransactionalTask,
|
||||
)
|
||||
from celery import Task
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class BaseTaskTest(TestCase):
|
||||
|
||||
@@ -4,6 +4,14 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import include, path
|
||||
from rest_framework import serializers, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from apps.core.pagination import StandardPagination
|
||||
from apps.core.viewsets import (
|
||||
BaseViewSet,
|
||||
@@ -13,14 +21,6 @@ from apps.core.viewsets import (
|
||||
)
|
||||
from apps.organization.models import Organization
|
||||
from apps.user.models import Profile, User
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import include, path
|
||||
from rest_framework import serializers, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from tests.apps.organization.factories import OrganizationFactory, fake
|
||||
from tests.apps.user.factories import ProfileFactory, UserFactory
|
||||
|
||||
|
||||
Reference in New Issue
Block a user