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

@@ -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)