mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 02:03:11 -04:00
Also store consent to research against a service
It makes most sense to collect this at the same time as the estimated volumes. Which means we need to store it somewhere; we can’t put it straight into the ticket.
This commit is contained in:
@@ -364,6 +364,7 @@ class Service(db.Model, Versioned):
|
|||||||
volume_sms = db.Column(db.Integer(), nullable=True, unique=False)
|
volume_sms = db.Column(db.Integer(), nullable=True, unique=False)
|
||||||
volume_email = db.Column(db.Integer(), nullable=True, unique=False)
|
volume_email = db.Column(db.Integer(), nullable=True, unique=False)
|
||||||
volume_letter = db.Column(db.Integer(), nullable=True, unique=False)
|
volume_letter = db.Column(db.Integer(), nullable=True, unique=False)
|
||||||
|
consent_to_research = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
organisation = db.relationship(
|
organisation = db.relationship(
|
||||||
'Organisation',
|
'Organisation',
|
||||||
|
|||||||
@@ -14,17 +14,19 @@ revision = '0260_service_volumes'
|
|||||||
down_revision = '0259_remove_service_postage'
|
down_revision = '0259_remove_service_postage'
|
||||||
|
|
||||||
|
|
||||||
TABLES_AND_CHANNELS = product(
|
TABLES = ['services', 'services_history']
|
||||||
('services', 'services_history'),
|
CHANNELS = ['volume_{}'.format(channel) for channel in ('email', 'letter', 'sms')]
|
||||||
('volume_{}'.format(channel) for channel in ('email', 'letter', 'sms')),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
for table, channel in TABLES_AND_CHANNELS:
|
for table in TABLES:
|
||||||
op.add_column(table, sa.Column(channel, sa.Integer(), nullable=True))
|
op.add_column(table, sa.Column('consent_to_research', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||||
|
for channel in CHANNELS:
|
||||||
|
op.add_column(table, sa.Column(channel, sa.Integer(), nullable=True))
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
for table, channel in TABLES_AND_CHANNELS:
|
for table in TABLES:
|
||||||
op.drop_column(table, channel)
|
op.drop_column(table, 'consent_to_research')
|
||||||
|
for channel in CHANNELS:
|
||||||
|
op.drop_column(table, channel)
|
||||||
|
|||||||
@@ -644,6 +644,30 @@ def test_update_service_sets_volumes(
|
|||||||
assert getattr(sample_service, field) == expected_persisted
|
assert getattr(sample_service, field) == expected_persisted
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('value, expected_status, expected_persisted', (
|
||||||
|
(True, 200, True),
|
||||||
|
(False, 200, False),
|
||||||
|
('Yes', 400, False),
|
||||||
|
))
|
||||||
|
def test_update_service_sets_research_consent(
|
||||||
|
admin_request,
|
||||||
|
sample_service,
|
||||||
|
value,
|
||||||
|
expected_status,
|
||||||
|
expected_persisted,
|
||||||
|
):
|
||||||
|
assert sample_service.consent_to_research is False
|
||||||
|
admin_request.post(
|
||||||
|
'service.update_service',
|
||||||
|
service_id=sample_service.id,
|
||||||
|
_data={
|
||||||
|
'consent_to_research': value,
|
||||||
|
},
|
||||||
|
_expected_status=expected_status,
|
||||||
|
)
|
||||||
|
assert sample_service.consent_to_research is expected_persisted
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def service_with_no_permissions(notify_db, notify_db_session):
|
def service_with_no_permissions(notify_db, notify_db_session):
|
||||||
return create_service(service_permissions=[])
|
return create_service(service_permissions=[])
|
||||||
|
|||||||
Reference in New Issue
Block a user