Files
mostovik-backend/tests/apps/organizations/test_models.py
Aleksandr Meshchriakov 0f17ff6773
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 26s
CI/CD Pipeline / Build and Push Images (push) Successful in 6s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s
Add organizations v2 API and registry enrichment
2026-05-06 19:04:46 +02:00

58 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Tests for organizations models."""
from django.test import TestCase
from organizations.models import Organization
class OrganizationModelTest(TestCase):
"""Checks canonical organization model constraints and rendering."""
def test_legal_entity_can_store_kpp_and_ogrn_without_ogrip(self):
organization = Organization.objects.create(
name='ООО "Ромашка"',
inn="7707083893",
kpp="770701001",
ogrn="1027700132195",
)
self.assertIsNotNone(organization.uid)
self.assertEqual(organization.ogrip, "")
self.assertEqual(str(organization), 'ООО "Ромашка" (7707083893)')
def test_individual_entrepreneur_can_store_ogrip_without_kpp_and_ogrn(self):
organization = Organization.objects.create(
name="ИП Иванов Иван Иванович",
inn="500100732259",
ogrip="304500116000157",
)
self.assertEqual(organization.kpp, "")
self.assertEqual(organization.ogrn, "")
self.assertEqual(organization.ogrip, "304500116000157")
def test_legal_entities_can_share_inn_with_different_kpp(self):
Organization.objects.create(
name='ООО "Ромашка" головной офис',
inn="7707083893",
kpp="770701001",
ogrn="1027700132195",
)
branch = Organization.objects.create(
name='ООО "Ромашка" филиал',
inn="7707083893",
kpp="780101001",
ogrn="1027700132195",
)
self.assertEqual(branch.inn, "7707083893")
self.assertEqual(branch.kpp, "780101001")
def test_name_only_organization_is_allowed(self):
organization = Organization.objects.create(
name="Общество с ограниченной ответственностью Ромашка",
)
self.assertEqual(organization.inn, "")
self.assertEqual(organization.name, "Общество с ограниченной ответственностью Ромашка")