-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5689 from uktrade/great_url_none
Great URL can be null
- Loading branch information
Showing
2 changed files
with
41 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
from datahub.company_activity.models import Great, IngestedFile | ||
from datahub.company_activity.tasks.ingest_company_activity import BUCKET, GREAT_PREFIX | ||
from datahub.company_activity.tasks.ingest_great_data import ( | ||
GreatIngestionTask, ingest_great_data, REGION, | ||
DATE_FORMAT, GreatIngestionTask, ingest_great_data, REGION, | ||
) | ||
from datahub.company_activity.tests.factories import ( | ||
CompanyActivityGreatFactory, | ||
|
@@ -109,13 +109,13 @@ def test_skip_unchanged_records(self, test_file_path): | |
Test that we skip updating records whose published date is older than the last | ||
file ingestion date | ||
""" | ||
yesterday = datetime.now() - timedelta(1) | ||
yesterday = datetime.strftime(datetime.now() - timedelta(1), DATE_FORMAT) | ||
CompanyActivityIngestedFileFactory(created_on=datetime.now()) | ||
record = json.dumps(dict( | ||
object={ | ||
'id': 'dit:directoryFormsApi:Submission:5249', | ||
'published': yesterday, | ||
'attributedT': { | ||
'attributedTo': { | ||
'type': 'dit:directoryFormsApi:SubmissionAction:gov-notify-email', | ||
'id': 'dit:directoryFormsApi:SubmissionType:export-support-service', | ||
}, | ||
|
@@ -156,38 +156,9 @@ def test_invalid_country_code(self): | |
"object": { | ||
"id": "dit:directoryFormsApi:Submission:5249", | ||
"published": "2024-09-19T14:00:34.069Z", | ||
"attributedTo": { | ||
"type": "dit:directoryFormsApi:SubmissionAction:gov-notify-email", | ||
"id": "dit:directoryFormsApi:SubmissionType:export-support-service" | ||
}, | ||
"url": "https://kane.net/", | ||
"dit:directoryFormsApi:Submission:Meta": { | ||
"action_name": "gov-notify-email", | ||
"template_id": "76f12003-74e8-4e6b-bbe9-8edc1b8619ae", | ||
"email_address": "[email protected]" | ||
}, | ||
"dit:directoryFormsApi:Submission:Data": { | ||
"comment": "Issue why why morning save parent southern.", | ||
"country": "ZZ", | ||
"full_name": "Tina Gray", | ||
"website_url": "https://www.henderson-thomas.info/", | ||
"company_name": "Foster, Murphy and Diaz", | ||
"company_size": "1 - 10", | ||
"phone_number": "12345678", | ||
"terms_agreed": true, | ||
"email_address": "[email protected]", | ||
"opportunities": ["https://white.net/app/tagscategory.php"], | ||
"role_in_company": "test", | ||
"opportunity_urls": "https://www.brown-andrade.com/wp-content/tagfaq.htm" | ||
"country": "ZZ" | ||
} | ||
}, | ||
"actor": { | ||
"type": "dit:directoryFormsApi:Submission:Sender", | ||
"id": "dit:directoryFormsApi:Sender:1041", | ||
"dit:emailAddress": "[email protected]", | ||
"dit:isBlacklisted": true, | ||
"dit:isWhitelisted": false, | ||
"dit:blackListedReason": null | ||
} | ||
} | ||
""" | ||
|
@@ -201,3 +172,34 @@ def test_invalid_country_code(self): | |
expected_message = 'Could not match country with iso code: ZZ, ' + \ | ||
'for form: 5249' | ||
assert sentry_event['logentry']['message'] == expected_message | ||
|
||
@pytest.mark.django_db | ||
@mock_aws | ||
def test_null_url(self, test_file_path): | ||
""" | ||
Test that we can ingest records with URL field null | ||
""" | ||
initial_count = Great.objects.count() | ||
data = """ | ||
{ | ||
"object": { | ||
"id": "dit:directoryFormsApi:Submission:5249", | ||
"published": "2024-09-19T14:00:34.069Z", | ||
"url": null | ||
} | ||
} | ||
""" | ||
task = GreatIngestionTask() | ||
task.json_to_model(json.loads(data)) | ||
assert Great.objects.count() == initial_count + 1 | ||
data = """ | ||
{ | ||
"object": { | ||
"id": "dit:directoryFormsApi:Submission:5250", | ||
"published": "2024-09-19T15:00:34.069Z" | ||
} | ||
} | ||
""" | ||
task = GreatIngestionTask() | ||
task.json_to_model(json.loads(data)) | ||
assert Great.objects.count() == initial_count + 2 |