Add initial implementations for forms and organization apps with serializers, factories, and admin configurations
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
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 / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
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:
@@ -16,19 +16,39 @@ class FormF3RecordFactory(factory.django.DjangoModelFactory):
|
||||
model = FormF3Record
|
||||
|
||||
organization = factory.SubFactory(OrganizationFactory)
|
||||
load_batch = factory.LazyAttribute(lambda _: fake.uuid4())
|
||||
load_batch = factory.Sequence(lambda n: n + 1)
|
||||
report_year = 2026
|
||||
report_quarter = 1
|
||||
|
||||
# Кадры
|
||||
avg_employees = factory.LazyAttribute(lambda _: fake.random_int(min=50, max=5000))
|
||||
production_workers = factory.LazyAttribute(lambda _: fake.random_int(min=20, max=3000))
|
||||
engineering_workers = factory.LazyAttribute(lambda _: fake.random_int(min=10, max=500))
|
||||
administrative_workers = factory.LazyAttribute(lambda _: fake.random_int(min=5, max=300))
|
||||
production_workers = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=20, max=3000)
|
||||
)
|
||||
engineering_workers = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=10, max=500)
|
||||
)
|
||||
administrative_workers = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=5, max=300)
|
||||
)
|
||||
|
||||
# Оборудование
|
||||
total_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=10, max=1000))
|
||||
domestic_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=5, max=500))
|
||||
imported_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=5, max=500))
|
||||
domestic_equipment = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=5, max=500)
|
||||
)
|
||||
imported_equipment = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=5, max=500)
|
||||
)
|
||||
|
||||
# Износ
|
||||
physical_wear_percent = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=0, max_value=100, left_digits=3, right_digits=2))
|
||||
utilization_rate = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=0, max_value=100, left_digits=3, right_digits=2))
|
||||
physical_wear_percent = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=0, max_value=100, left_digits=3, right_digits=2
|
||||
)
|
||||
)
|
||||
utilization_rate = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=0, max_value=100, left_digits=3, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Tests for FormF3 model."""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from .factories import FormF3RecordFactory
|
||||
@@ -19,7 +21,9 @@ class FormF3RecordModelTest(TestCase):
|
||||
|
||||
def test_record_str_representation(self):
|
||||
"""Test string representation."""
|
||||
expected = f"Ф-3: {self.record.organization} ({self.record.load_batch})"
|
||||
expected = (
|
||||
f"Ф-3: {self.record.organization.name} (batch: {self.record.load_batch})"
|
||||
)
|
||||
self.assertEqual(str(self.record), expected)
|
||||
|
||||
def test_organization_relationship(self):
|
||||
@@ -27,8 +31,8 @@ class FormF3RecordModelTest(TestCase):
|
||||
self.assertIsNotNone(self.record.organization.inn)
|
||||
|
||||
def test_integer_fields(self):
|
||||
"""Test integer fields."""
|
||||
self.assertIsInstance(self.record.avg_employees, int)
|
||||
"""Test field types match the model contract."""
|
||||
self.assertIsInstance(self.record.avg_employees, (int, Decimal))
|
||||
self.assertIsInstance(self.record.total_equipment, int)
|
||||
|
||||
def test_decimal_fields_precision(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ class FormF3ServiceTest(TestCase):
|
||||
|
||||
def test_get_by_load_batch(self):
|
||||
"""Test getting records by load batch."""
|
||||
batch_id = "test-batch-f3"
|
||||
batch_id = 103
|
||||
FormF3RecordFactory.create(load_batch=batch_id)
|
||||
FormF3RecordFactory.create(load_batch=batch_id)
|
||||
|
||||
@@ -32,10 +32,10 @@ class FormF3ServiceTest(TestCase):
|
||||
|
||||
def test_delete_by_load_batch(self):
|
||||
"""Test deleting records by load batch."""
|
||||
batch_id = "delete-batch-f3"
|
||||
batch_id = 303
|
||||
FormF3RecordFactory.create(load_batch=batch_id)
|
||||
FormF3RecordFactory.create(load_batch=batch_id)
|
||||
other = FormF3RecordFactory.create(load_batch="keep-batch")
|
||||
other = FormF3RecordFactory.create(load_batch=403)
|
||||
|
||||
count = FormF3Service.delete_by_load_batch(batch_id)
|
||||
self.assertEqual(count, 2)
|
||||
@@ -50,21 +50,20 @@ class FormF3ParserTest(TestCase):
|
||||
|
||||
def test_get_column_mappings_returns_mappings(self):
|
||||
"""Test get_column_mappings returns correct mappings."""
|
||||
parser = FormF3Parser()
|
||||
parser = FormF3Parser(report_year=2026, report_quarter=1)
|
||||
mappings = parser.get_column_mappings()
|
||||
|
||||
self.assertIsInstance(mappings, list)
|
||||
self.assertTrue(len(mappings) > 0)
|
||||
|
||||
field_names = [m.field_name for m in mappings]
|
||||
self.assertIn("inn", field_names)
|
||||
self.assertIn("avg_employees", field_names)
|
||||
self.assertIn("total_equipment", field_names)
|
||||
|
||||
def test_create_record_creates_organization(self):
|
||||
"""Test create_record creates organization if not exists."""
|
||||
parser = FormF3Parser()
|
||||
parser.load_batch = "test-batch"
|
||||
parser = FormF3Parser(report_year=2026, report_quarter=1)
|
||||
parser.load_batch = 503
|
||||
|
||||
row_data = {
|
||||
"inn": "3234567890",
|
||||
|
||||
Reference in New Issue
Block a user