Remove service.postage and choose_postage permission from the code and tests

This commit is contained in:
Pea Tyczynska
2019-02-11 18:20:34 +00:00
parent a6660b7d91
commit 8ef581de69
6 changed files with 13 additions and 36 deletions

View File

@@ -163,8 +163,7 @@ def sample_service(
limit=1000,
email_from=None,
permissions=None,
research_mode=None,
postage="second",
research_mode=None
):
if user is None:
user = create_user()
@@ -176,8 +175,7 @@ def sample_service(
'message_limit': limit,
'restricted': restricted,
'email_from': email_from,
'created_by': user,
"postage": postage,
'created_by': user
}
service = Service.query.filter_by(name=service_name).first()
if not service:

View File

@@ -3,7 +3,7 @@ from datetime import datetime
import pytest
from freezegun import freeze_time
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.exc import FlushError, NoResultFound
from app import db
@@ -95,7 +95,6 @@ def test_create_service(notify_db_session):
assert service_db.email_from == 'email_from'
assert service_db.research_mode is False
assert service_db.prefix_sms is True
assert service_db.postage == 'second'
assert service.active is True
assert user in service_db.users
assert service_db.organisation_type == 'central'
@@ -380,12 +379,10 @@ def test_create_service_creates_a_history_record_with_current_data(notify_db_ses
assert service_from_db.name == service_history.name
assert service_from_db.version == 1
assert service_from_db.version == service_history.version
assert service_from_db.postage == 'second'
assert user.id == service_history.created_by_id
assert service_from_db.created_by.id == service_history.created_by_id
assert service_from_db.dvla_organisation_id == DVLA_ORG_HM_GOVERNMENT
assert service_history.dvla_organisation_id == DVLA_ORG_HM_GOVERNMENT
assert service_history.postage == 'second'
def test_update_service_creates_a_history_record_with_current_data(notify_db_session):
@@ -463,28 +460,6 @@ def test_update_service_permission_creates_a_history_record_with_current_data(no
assert Service.get_history_model().query.filter_by(name='service_name').all()[2].version == 3
def test_service_postage_constraint_on_create(notify_db_session):
user = create_user()
assert Service.query.count() == 0
assert Service.get_history_model().query.count() == 0
service = Service(name="service_name",
email_from="email_from",
message_limit=1000,
restricted=False,
created_by=user,
postage='third')
with pytest.raises(expected_exception=SQLAlchemyError):
dao_create_service(service, user)
def test_service_postage_constraint_on_update(notify_db_session):
create_service()
service_from_db = Service.query.first()
service_from_db.postage = 'third'
with pytest.raises(expected_exception=SQLAlchemyError):
dao_update_service(service_from_db)
def test_create_service_and_history_is_transactional(notify_db_session):
user = create_user()
assert Service.query.count() == 0

View File

@@ -37,6 +37,8 @@ def test_create_template(sample_service, sample_user, template_type, subject):
'service': sample_service,
'created_by': sample_user
}
if template_type == 'letter':
data['postage'] = 'second'
if subject:
data.update({'subject': subject})
template = Template(**data)
@@ -69,6 +71,7 @@ def test_create_template_with_reply_to(sample_service, sample_user):
'service': sample_service,
'created_by': sample_user,
'reply_to': letter_contact.id,
'postage': 'second'
}
template = Template(**data)
dao_create_template(template)
@@ -132,6 +135,7 @@ def test_dao_update_template_reply_to_none_to_some(sample_service, sample_user):
'content': "Template content",
'service': sample_service,
'created_by': sample_user,
'postage': 'second'
}
template = Template(**data)
dao_create_template(template)
@@ -162,7 +166,8 @@ def test_dao_update_template_reply_to_some_to_some(sample_service, sample_user):
'content': "Template content",
'service': sample_service,
'created_by': sample_user,
'service_letter_contact_id': letter_contact.id
'service_letter_contact_id': letter_contact.id,
'postage': 'second',
}
template = Template(**data)
dao_create_template(template)
@@ -186,7 +191,8 @@ def test_dao_update_template_reply_to_some_to_none(sample_service, sample_user):
'content': "Template content",
'service': sample_service,
'created_by': sample_user,
'service_letter_contact_id': letter_contact.id
'service_letter_contact_id': letter_contact.id,
'postage': 'second'
}
template = Template(**data)
dao_create_template(template)

View File

@@ -83,7 +83,6 @@ def create_service(
prefix_sms=True,
message_limit=1000,
organisation_type='central',
postage='second',
check_if_service_exists=False
):
if check_if_service_exists:
@@ -96,8 +95,7 @@ def create_service(
email_from=email_from if email_from else service_name.lower().replace(' ', '.'),
created_by=user if user else create_user(email='{}@digital.cabinet-office.gov.uk'.format(uuid.uuid4())),
prefix_sms=prefix_sms,
organisation_type=organisation_type,
postage=postage
organisation_type=organisation_type
)
dao_create_service(service, service.created_by, service_id, service_permissions=service_permissions)

View File

@@ -141,7 +141,6 @@ def test_get_service_by_id(admin_request, sample_service):
assert 'branding' not in json_resp['data']
assert json_resp['data']['dvla_organisation'] == '001'
assert json_resp['data']['prefix_sms'] is True
assert json_resp['data']['postage'] == 'second'
assert json_resp['data']['letter_logo_filename'] == 'hm-government'