Don’t allow indexing on service model

Making people use a property is a sure way to make sure they’re spelling
the name of the property correctly, and allows us to easily swap out
properties that call through to the underlying JSON, and properties
which are implemented as methods.
This commit is contained in:
Chris Hill-Scott
2018-10-26 12:13:04 +01:00
parent 780b9bb715
commit e1197c54a5
10 changed files with 17 additions and 12 deletions

View File

@@ -176,6 +176,7 @@ def service_json(
'service_callback_api': service_callback_api,
'prefix_sms': prefix_sms,
'postage': postage,
'contact_link': None,
}

View File

@@ -9,6 +9,7 @@ from flask import url_for
from freezegun import freeze_time
from app.main.views.jobs import get_status_filters, get_time_left
from app.notify_client.models import Service
from tests.conftest import (
SERVICE_ONE_ID,
active_caseworking_user,
@@ -438,7 +439,7 @@ STATISTICS = {
def test_get_status_filters_calculates_stats(client):
ret = get_status_filters({'id': 'foo'}, 'sms', STATISTICS)
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
assert {label: count for label, _option, _link, count in ret} == {
'total': 6,
@@ -449,7 +450,7 @@ def test_get_status_filters_calculates_stats(client):
def test_get_status_filters_in_right_order(client):
ret = get_status_filters({'id': 'foo'}, 'sms', STATISTICS)
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
assert [label for label, _option, _link, _count in ret] == [
'total', 'sending', 'delivered', 'failed'
@@ -457,7 +458,7 @@ def test_get_status_filters_in_right_order(client):
def test_get_status_filters_constructs_links(client):
ret = get_status_filters({'id': 'foo'}, 'sms', STATISTICS)
ret = get_status_filters(Service({'id': 'foo'}), 'sms', STATISTICS)
link = ret[0][2]
assert link == '/services/foo/notifications/sms?status={}'.format(quote('sending,delivered,failed'))