46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Tests for deprecated populate_organizations command."""
|
||
|
||
from apps.parsers.models import GenericParserRecord
|
||
from django.core.management import call_command
|
||
from django.test import TestCase
|
||
from organizations.models import Organization
|
||
|
||
|
||
class PopulateOrganizationsCommandTest(TestCase):
|
||
"""Checks parser-derived organization population is disabled."""
|
||
|
||
def test_command_does_not_create_organizations_from_parser_records(self):
|
||
GenericParserRecord.objects.create(
|
||
load_batch=1,
|
||
source="arbitration",
|
||
external_id="name-only-1",
|
||
organisation_name='ООО "Ромашка"',
|
||
inn="7707083893",
|
||
ogrn="1027700132195",
|
||
)
|
||
|
||
call_command("populate_organizations", silent=True, verbosity=0)
|
||
|
||
self.assertEqual(Organization.objects.count(), 0)
|
||
|
||
def test_command_does_not_update_existing_organization_identity(self):
|
||
organization = Organization.objects.create(
|
||
name='ООО "Источник"',
|
||
inn="7707083893",
|
||
ogrn="1027700132195",
|
||
)
|
||
GenericParserRecord.objects.create(
|
||
load_batch=1,
|
||
source="trudvsem",
|
||
external_id="branch-with-kpp",
|
||
organisation_name='ООО "Источник"',
|
||
inn="7707083893",
|
||
ogrn="1027700132195",
|
||
payload={"company": {"kpp": "770701001"}},
|
||
)
|
||
|
||
call_command("populate_organizations", silent=True, verbosity=0)
|
||
|
||
organization.refresh_from_db()
|
||
self.assertEqual(organization.kpp, "")
|