mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Merge pull request #1709 from alphagov/ken-fix-letter-serialization
Fix serialization on precompiled letter
This commit is contained in:
@@ -1306,7 +1306,7 @@ class Notification(db.Model):
|
|||||||
serialized['line_4'] = col.get('address_line_4')
|
serialized['line_4'] = col.get('address_line_4')
|
||||||
serialized['line_5'] = col.get('address_line_5')
|
serialized['line_5'] = col.get('address_line_5')
|
||||||
serialized['line_6'] = col.get('address_line_6')
|
serialized['line_6'] = col.get('address_line_6')
|
||||||
serialized['postcode'] = self.personalisation['postcode']
|
serialized['postcode'] = col.get('postcode')
|
||||||
serialized['estimated_delivery'] = \
|
serialized['estimated_delivery'] = \
|
||||||
get_letter_timings(serialized['created_at'])\
|
get_letter_timings(serialized['created_at'])\
|
||||||
.earliest_delivery\
|
.earliest_delivery\
|
||||||
|
|||||||
@@ -307,3 +307,15 @@ def test_letter_notification_serializes_correctly(client, sample_letter_notifica
|
|||||||
assert json['line_1'] == 'test'
|
assert json['line_1'] == 'test'
|
||||||
assert json['line_2'] == 'London'
|
assert json['line_2'] == 'London'
|
||||||
assert json['postcode'] == 'N1'
|
assert json['postcode'] == 'N1'
|
||||||
|
|
||||||
|
|
||||||
|
def test_letter_notification_postcode_can_be_null_for_precompiled_letters(client, sample_letter_notification):
|
||||||
|
sample_letter_notification.personalisation = {
|
||||||
|
'address_line_1': 'test',
|
||||||
|
'address_line_2': 'London',
|
||||||
|
}
|
||||||
|
|
||||||
|
json = sample_letter_notification.serialize()
|
||||||
|
assert json['line_1'] == 'test'
|
||||||
|
assert json['line_2'] == 'London'
|
||||||
|
assert json['postcode'] is None
|
||||||
|
|||||||
Reference in New Issue
Block a user