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,16 +16,26 @@ class FormF6RecordFactory(factory.django.DjangoModelFactory):
|
||||
model = FormF6Record
|
||||
|
||||
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
|
||||
|
||||
# Категоризация
|
||||
row_code = factory.LazyAttribute(lambda _: fake.numerify("###"))
|
||||
category = factory.LazyAttribute(lambda _: fake.random_element(["Металлорежущее", "Кузнечно-прессовое", "Литейное", "Сварочное"]))
|
||||
category = factory.LazyAttribute(
|
||||
lambda _: fake.random_element(
|
||||
["Металлорежущее", "Кузнечно-прессовое", "Литейное", "Сварочное"]
|
||||
)
|
||||
)
|
||||
|
||||
# Общие данные
|
||||
total_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=10, max=500))
|
||||
domestic_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=5, max=250))
|
||||
imported_equipment = factory.LazyAttribute(lambda _: fake.random_int(min=5, max=250))
|
||||
domestic_equipment = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=5, max=250)
|
||||
)
|
||||
imported_equipment = factory.LazyAttribute(
|
||||
lambda _: fake.random_int(min=5, max=250)
|
||||
)
|
||||
|
||||
# Возрастная структура
|
||||
age_under_5 = factory.LazyAttribute(lambda _: fake.random_int(min=0, max=50))
|
||||
@@ -38,6 +48,18 @@ class FormF6RecordFactory(factory.django.DjangoModelFactory):
|
||||
cnc_total = factory.LazyAttribute(lambda _: fake.random_int(min=0, max=100))
|
||||
|
||||
# Показатели
|
||||
avg_shift_work = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1, max_value=3, left_digits=1, 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))
|
||||
avg_shift_work = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1, max_value=3, left_digits=1, 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
|
||||
)
|
||||
)
|
||||
|
||||
@@ -19,7 +19,10 @@ class FormF6RecordModelTest(TestCase):
|
||||
|
||||
def test_record_str_representation(self):
|
||||
"""Test string representation."""
|
||||
expected = f"Ф-6: {self.record.organization} - {self.record.row_code}"
|
||||
expected = (
|
||||
f"Ф-6: {self.record.category or self.record.row_code} "
|
||||
f"({self.record.organization.name})"
|
||||
)
|
||||
self.assertEqual(str(self.record), expected)
|
||||
|
||||
def test_organization_relationship(self):
|
||||
@@ -28,7 +31,7 @@ class FormF6RecordModelTest(TestCase):
|
||||
|
||||
def test_string_fields_max_length(self):
|
||||
"""Test string fields max length."""
|
||||
self.assertEqual(self.record._meta.get_field("row_code").max_length, 10)
|
||||
self.assertEqual(self.record._meta.get_field("row_code").max_length, 20)
|
||||
self.assertEqual(self.record._meta.get_field("category").max_length, 200)
|
||||
|
||||
def test_integer_fields(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ class FormF6ServiceTest(TestCase):
|
||||
|
||||
def test_get_by_load_batch(self):
|
||||
"""Test getting records by load batch."""
|
||||
batch_id = "test-batch-f6"
|
||||
batch_id = 106
|
||||
FormF6RecordFactory.create(load_batch=batch_id)
|
||||
FormF6RecordFactory.create(load_batch=batch_id)
|
||||
|
||||
@@ -32,10 +32,10 @@ class FormF6ServiceTest(TestCase):
|
||||
|
||||
def test_delete_by_load_batch(self):
|
||||
"""Test deleting records by load batch."""
|
||||
batch_id = "delete-batch-f6"
|
||||
batch_id = 306
|
||||
FormF6RecordFactory.create(load_batch=batch_id)
|
||||
FormF6RecordFactory.create(load_batch=batch_id)
|
||||
other = FormF6RecordFactory.create(load_batch="keep-batch")
|
||||
other = FormF6RecordFactory.create(load_batch=406)
|
||||
|
||||
count = FormF6Service.delete_by_load_batch(batch_id)
|
||||
self.assertEqual(count, 2)
|
||||
@@ -50,21 +50,20 @@ class FormF6ParserTest(TestCase):
|
||||
|
||||
def test_get_column_mappings_returns_mappings(self):
|
||||
"""Test get_column_mappings returns correct mappings."""
|
||||
parser = FormF6Parser()
|
||||
parser = FormF6Parser(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("row_code", field_names)
|
||||
self.assertIn("total_equipment", field_names)
|
||||
|
||||
def test_create_record_creates_organization(self):
|
||||
"""Test create_record creates organization if not exists."""
|
||||
parser = FormF6Parser()
|
||||
parser.load_batch = "test-batch"
|
||||
parser = FormF6Parser(report_year=2026, report_quarter=1)
|
||||
parser.load_batch = 506
|
||||
|
||||
row_data = {
|
||||
"inn": "6234567890",
|
||||
|
||||
Reference in New Issue
Block a user