Persist simple polygons in the db.

They are being sent over from admin, and persisted
in the db so we can send them on to the broadcast
provider later on.
This commit is contained in:
Pea Tyczynska
2020-09-02 14:55:23 +01:00
parent 06ff8723d2
commit 5cf6e1cf72
6 changed files with 25 additions and 9 deletions

View File

@@ -11,7 +11,10 @@ from tests.app.db import create_broadcast_message, create_template, create_servi
def test_get_broadcast_message(admin_request, sample_service):
t = create_template(sample_service, BROADCAST_TYPE)
bm = create_broadcast_message(t, areas=['place A', 'region B'])
bm = create_broadcast_message(t, areas={
"areas": ['place A', 'region B'],
"simple_polygons": [[50.1, 1.2], [50.12, 1.2]]
})
response = admin_request.get(
'broadcast_message.get_broadcast_message',
@@ -177,7 +180,10 @@ def test_update_broadcast_message_doesnt_allow_edits_after_broadcast_goes_live(a
def test_update_broadcast_message_sets_finishes_at_separately(admin_request, sample_service):
t = create_template(sample_service, BROADCAST_TYPE)
bm = create_broadcast_message(t, areas=['manchester'])
bm = create_broadcast_message(
t,
areas={"areas": ['london'], "simple_polygons": [[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]}
)
response = admin_request.post(
'broadcast_message.update_broadcast_message',

View File

@@ -11,7 +11,11 @@ from tests.app.db import create_template, create_broadcast_message, create_broad
def test_send_broadcast_message_sends_data_correctly(sample_service):
template = create_template(sample_service, BROADCAST_TYPE)
broadcast_message = create_broadcast_message(template, areas=['london'], status=BroadcastStatusType.BROADCASTING)
broadcast_message = create_broadcast_message(
template,
areas={"areas": ['london'], "simple_polygons": [[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]},
status=BroadcastStatusType.BROADCASTING
)
with requests_mock.Mocker() as request_mock:
request_mock.post("http://test-cbc-proxy/broadcasts/stub-1", json={'valid': 'true'}, status_code=200)
@@ -29,7 +33,11 @@ def test_send_broadcast_message_sends_data_correctly(sample_service):
def test_send_broadcast_message_sends_old_version_of_template(sample_service):
template = create_template(sample_service, BROADCAST_TYPE, content='first content')
broadcast_message = create_broadcast_message(template, areas=['london'], status=BroadcastStatusType.BROADCASTING)
broadcast_message = create_broadcast_message(
template,
areas={"areas": ['london'], "simple_polygons": [[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]]},
status=BroadcastStatusType.BROADCASTING
)
template.content = 'second content'
dao_update_template(template)

View File

@@ -1006,7 +1006,7 @@ def create_broadcast_message(
status=BroadcastStatusType.DRAFT,
starts_at=None,
finishes_at=None,
areas=[],
areas={},
):
broadcast_message = BroadcastMessage(
service_id=template.service_id,