Removing platform_default as a concept. No service actually wants to send letters with the default hm-government logo so we are going to remove it as a constraint.

However, until we can create a letter without a logo, we will still default to hm-government, because the dvla_organisation is set on the service.
This does simplify the code.
Also removed the inserts to letter_branding in the data migration file, because we can deploy this before the rest of the work is finished. But we will need to do it later.
This commit is contained in:
Rebecca Law
2019-01-25 15:03:01 +00:00
parent 7ee1d67df7
commit e030c2be88
11 changed files with 65 additions and 85 deletions

View File

@@ -1,6 +1,5 @@
import json
import pytest
from app.models import LetterBranding
from tests import create_authorization_header
@@ -8,19 +7,21 @@ from tests.app.db import create_letter_branding
def test_get_all_letter_brands(client, notify_db_session):
platform_default = create_letter_branding()
hm_gov = create_letter_branding()
test_domain_branding = create_letter_branding(
name='test domain', filename='test-domain', domain='test.domain', platform_default=False
name='test domain', filename='test-domain', domain='test.domain'
)
response = client.get('/letter-branding', headers=[create_authorization_header()])
assert response.status_code == 200
json_response = json.loads(response.get_data(as_text=True))
assert len(json_response) == 2
for brand in json_response:
if brand['id'] == platform_default:
platform_default.serialize() == brand
if brand['id'] == str(hm_gov.id):
assert hm_gov.serialize() == brand
elif brand['id'] == str(test_domain_branding.id):
assert test_domain_branding.serialize() == brand
else:
test_domain_branding.serialize() == brand
assert False
def test_create_letter_branding(client, notify_db_session):
@@ -42,26 +43,6 @@ def test_create_letter_branding(client, notify_db_session):
assert letter_brand.name == form['name']
assert letter_brand.domain == form['domain']
assert letter_brand.filename == form['filename']
assert not letter_brand.platform_default
def test_create_letter_branding_returns_400_if_platform_default_is_passed_in_the_form(client, notify_db_session):
form = {
'name': 'super brand',
'domain': 'super.brand',
'filename': 'super-brand',
'platform_default': True
}
response = client.post(
'/letter-branding',
data=json.dumps(form),
headers=[('Content-Type', 'application/json'), create_authorization_header()],
)
assert response.status_code == 400
json_resp = json.loads(response.get_data(as_text=True))
assert json_resp['errors'][0]['message'] == \
"Additional properties are not allowed (platform_default was unexpected)"
def test_create_letter_branding_returns_400_if_name_already_exists(client, notify_db_session):
@@ -102,5 +83,4 @@ def test_update_letter_branding_returns_400_when_integrity_error_is_thrown(
assert response.status_code == 400
json_resp = json.loads(response.get_data(as_text=True))
# Why is this name and not domain? copied this pattern from email_branding
assert json_resp['message'] == {"name": ["Duplicate domain 'duplicate'"]}