15
15
from datahub .company_activity .models import GreatExportEnquiry , IngestedFile
16
16
from datahub .company_activity .tasks .constants import BUCKET , GREAT_PREFIX , REGION
17
17
from datahub .company_activity .tasks .ingest_great_data import (
18
- GreatIngestionTask , ingest_great_data ,
18
+ GreatIngestionTask ,
19
+ ingest_great_data ,
19
20
)
20
21
from datahub .company_activity .tests .factories import (
21
22
GreatExportEnquiryFactory ,
25
26
26
27
@pytest .fixture
27
28
def test_file ():
28
- filepath = 'datahub/company_activity/tests/test_tasks/fixtures/great/20241023T000346.jsonl.gz'
29
+ filepath = (
30
+ 'datahub/company_activity/tests/test_tasks/fixtures/great/20241023T000346.jsonl.gz'
31
+ )
29
32
return open (filepath , 'rb' )
30
33
31
34
@@ -164,7 +167,7 @@ def test_company_name_mapping(self):
164
167
"id": "5250",
165
168
"created_at": "2024-09-19T14:00:34.069",
166
169
"data": {{
167
- "company_registration_number": 994349,
170
+ "company_registration_number": " 994349" ,
168
171
"business_name": "{ company .name } "
169
172
}}
170
173
}}
@@ -563,7 +566,7 @@ def test_boolean_field_mapping(self):
563
566
564
567
@pytest .mark .django_db
565
568
@mock_aws
566
- def test_long_field_values (self , test_file_path ):
569
+ def test_long_field_values (self ):
567
570
"""
568
571
Test that we can ingest records with long field values
569
572
"""
@@ -575,6 +578,7 @@ def test_long_field_values(self, test_file_path):
575
578
'that either need to be stored as TextFields if we need'
576
579
'the full value or truncated if we do not. Long long long.'
577
580
)
581
+
578
582
data = f"""
579
583
{{
580
584
"id": "5249",
@@ -589,10 +593,18 @@ def test_long_field_values(self, test_file_path):
589
593
"product_or_service_2": "{ long_text } ",
590
594
"product_or_service_3": "{ long_text } ",
591
595
"product_or_service_4": "{ long_text } ",
592
- "product_or_service_5": "{ long_text } "
596
+ "product_or_service_5": "{ long_text } ",
597
+ "company_registration_number": "{ long_text } "
598
+
593
599
}}
594
600
}}
595
601
"""
596
602
task = GreatIngestionTask ()
597
603
task .json_to_model (json .loads (data ))
598
604
assert GreatExportEnquiry .objects .count () == initial_count + 1
605
+
606
+ result = GreatExportEnquiry .objects .get (form_id = '5249' ).company_id
607
+
608
+ company_result = Company .objects .get (id = result )
609
+
610
+ assert company_result .company_number is None
0 commit comments