Fix serialization on precompiled letter

Postcodes are required for created letters, but not for precompiled, this fix allows postcodes to be None in the model.
As postcodes are still required for created letter they should be caught by validation schemas in the POST handler
This commit is contained in:
Ken Tsang
2018-02-26 13:53:06 +00:00
parent 6ad868d22e
commit c14663d84a
2 changed files with 13 additions and 1 deletions

View File

@@ -307,3 +307,15 @@ def test_letter_notification_serializes_correctly(client, sample_letter_notifica
assert json['line_1'] == 'test'
assert json['line_2'] == 'London'
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