Skip to content

Commit 794dd8c

Browse files
committed
Handle empty company names from stova attendees
1 parent 593fc0d commit 794dd8c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

datahub/company_activity/tasks/ingest_stova_attendees.py

+6
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ def get_or_create_company(values: dict) -> Company | None:
180180
:returns: An existing `Company` if found or a newly created `Company`.
181181
"""
182182
company_name = values['company_name']
183+
if company_name == '' or company_name is None:
184+
logger.info(
185+
f'No company name available, skipping attendee {values["stova_attendee_id"]}'
186+
)
187+
return
188+
183189
company = Company.objects.filter(name__iexact=company_name).first()
184190
if company:
185191
return company

datahub/company_activity/tests/test_tasks/test_stova_attendee_ingestion_task.py

+20
Original file line numberDiff line numberDiff line change
@@ -527,3 +527,23 @@ def test_stova_attendee_does_not_create_attendee_when_interaction_fails(
527527
task._process_record(data)
528528

529529
assert StovaAttendee.objects.count() == 0
530+
531+
@pytest.mark.django_db
532+
@pytest.mark.parametrize(
533+
'company_name',
534+
(
535+
'',
536+
None,
537+
),
538+
)
539+
def test_get_or_create_company__returns_when_company_name_empty(
540+
self, s3_object_processor, test_file_path, caplog, company_name
541+
):
542+
"""Tests empty company names are logged and no company is created."""
543+
data = {'stova_attendee_id': 1234, 'company_name': company_name}
544+
ingestion_task = StovaAttendeeIngestionTask(test_file_path, s3_object_processor)
545+
546+
with caplog.at_level(logging.INFO):
547+
company = ingestion_task.get_or_create_company(data)
548+
assert 'No company name available, skipping attendee 1234' in caplog.text
549+
assert company is None

0 commit comments

Comments
 (0)