mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Merge pull request #3310 from alphagov/revert-3309-update-utils-coordinate-transformation
Revert "Update utils to bring in coordinate transformation"
This commit is contained in:
@@ -28,5 +28,5 @@ def cap_xml_polygon_to_list(polygon_string):
|
||||
[
|
||||
float(coordinate) for coordinate in pair.split(',')
|
||||
]
|
||||
for pair in polygon_string.strip().split(' ')
|
||||
for pair in polygon_string.split(' ')
|
||||
]
|
||||
|
||||
@@ -43,10 +43,7 @@ def create_broadcast():
|
||||
validate(broadcast_json, post_broadcast_schema)
|
||||
|
||||
polygons = Polygons(list(chain.from_iterable((
|
||||
[
|
||||
[[y, x] for x, y in polygon]
|
||||
for polygon in area['polygons']
|
||||
] for area in broadcast_json['areas']
|
||||
area['polygons'] for area in broadcast_json['areas']
|
||||
))))
|
||||
|
||||
template = BroadcastMessageTemplate.from_content(
|
||||
@@ -65,11 +62,6 @@ def create_broadcast():
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
if len(polygons) > 12 or polygons.point_count > 250:
|
||||
simple_polygons = polygons.smooth.simplify
|
||||
else:
|
||||
simple_polygons = polygons
|
||||
|
||||
broadcast_message = BroadcastMessage(
|
||||
service_id=authenticated_service.id,
|
||||
content=broadcast_json['content'],
|
||||
@@ -78,7 +70,7 @@ def create_broadcast():
|
||||
'areas': [
|
||||
area['name'] for area in broadcast_json['areas']
|
||||
],
|
||||
'simple_polygons': simple_polygons.as_coordinate_pairs_lat_long,
|
||||
'simple_polygons': polygons.smooth.simplify.as_coordinate_pairs_long_lat,
|
||||
},
|
||||
status=BroadcastStatusType.PENDING_APPROVAL,
|
||||
api_key_id=api_user.id,
|
||||
|
||||
@@ -38,7 +38,7 @@ notifications-python-client==6.0.2
|
||||
# PaaS
|
||||
awscli-cwlogs==1.4.6
|
||||
|
||||
git+https://github.com/alphagov/notifications-utils.git@45.0.1#egg=notifications-utils==45.0.1
|
||||
git+https://github.com/alphagov/notifications-utils.git@44.5.1#egg=notifications-utils==44.5.1
|
||||
|
||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
||||
prometheus-client==0.10.1
|
||||
|
||||
@@ -40,7 +40,7 @@ notifications-python-client==6.0.2
|
||||
# PaaS
|
||||
awscli-cwlogs==1.4.6
|
||||
|
||||
git+https://github.com/alphagov/notifications-utils.git@45.0.1#egg=notifications-utils==45.0.1
|
||||
git+https://github.com/alphagov/notifications-utils.git@44.5.1#egg=notifications-utils==44.5.1
|
||||
|
||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
||||
prometheus-client==0.10.1
|
||||
@@ -51,16 +51,16 @@ alembic==1.6.5
|
||||
amqp==1.4.9
|
||||
anyjson==0.3.3
|
||||
attrs==21.2.0
|
||||
awscli==1.20.24
|
||||
awscli==1.20.8
|
||||
bcrypt==3.2.0
|
||||
billiard==3.3.0.23
|
||||
bleach==3.3.0
|
||||
blinker==1.4
|
||||
boto==2.49.0
|
||||
boto3==1.18.24
|
||||
botocore==1.21.24
|
||||
boto3==1.18.8
|
||||
botocore==1.21.8
|
||||
certifi==2021.5.30
|
||||
charset-normalizer==2.0.4
|
||||
charset-normalizer==2.0.3
|
||||
click==8.0.1
|
||||
colorama==0.4.3
|
||||
dnspython==1.16.0
|
||||
@@ -68,9 +68,8 @@ docutils==0.15.2
|
||||
flask-redis==0.4.0
|
||||
geojson==2.5.0
|
||||
govuk-bank-holidays==0.9
|
||||
greenlet==1.1.1
|
||||
greenlet==1.1.0
|
||||
idna==3.2
|
||||
importlib-metadata==4.6.4
|
||||
Jinja2==3.0.1
|
||||
jmespath==0.10.0
|
||||
kombu==3.0.37
|
||||
@@ -79,12 +78,11 @@ MarkupSafe==2.0.1
|
||||
mistune==0.8.4
|
||||
orderedset==2.0.3
|
||||
packaging==21.0
|
||||
phonenumbers==8.12.30
|
||||
phonenumbers==8.12.28
|
||||
pyasn1==0.4.8
|
||||
pycparser==2.20
|
||||
pyparsing==2.4.7
|
||||
PyPDF2==1.26.0
|
||||
pyproj==3.0.1
|
||||
pyrsistent==0.18.0
|
||||
python-dateutil==2.8.2
|
||||
python-editor==1.0.4
|
||||
@@ -100,7 +98,5 @@ six==1.16.0
|
||||
smartypants==2.0.1
|
||||
soupsieve==2.2.1
|
||||
statsd==3.3.0
|
||||
typing-extensions==3.10.0.0
|
||||
urllib3==1.26.6
|
||||
webencodings==0.5.1
|
||||
zipp==3.5.0
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -103,9 +103,9 @@ def test_valid_post_cap_xml_broadcast_returns_201(
|
||||
assert response_json['personalisation'] is None
|
||||
assert response_json['service_id'] == str(sample_broadcast_service.id)
|
||||
assert len(response_json['simple_polygons']) == 1
|
||||
assert len(response_json['simple_polygons'][0]) == 29
|
||||
assert response_json['simple_polygons'][0][0] == [53.10569, 0.24453]
|
||||
assert response_json['simple_polygons'][0][-1] == [53.10569, 0.24453]
|
||||
assert len(response_json['simple_polygons'][0]) == 23
|
||||
assert response_json['simple_polygons'][0][0] == [53.10562, 0.244127]
|
||||
assert response_json['simple_polygons'][0][-1] == [53.10562, 0.244127]
|
||||
assert response_json['starts_at'] is None
|
||||
assert response_json['status'] == 'pending-approval'
|
||||
assert response_json['template_id'] is None
|
||||
@@ -114,27 +114,6 @@ def test_valid_post_cap_xml_broadcast_returns_201(
|
||||
assert response_json['updated_at'] is None
|
||||
|
||||
|
||||
def test_large_polygon_is_simplified(
|
||||
client,
|
||||
sample_broadcast_service,
|
||||
):
|
||||
auth_header = create_service_authorization_header(service_id=sample_broadcast_service.id)
|
||||
response = client.post(
|
||||
path='/v2/broadcast',
|
||||
data=sample_cap_xml_documents.WINDEMERE,
|
||||
headers=[('Content-Type', 'application/cap+xml'), auth_header],
|
||||
)
|
||||
assert response.status_code == 201
|
||||
|
||||
response_json = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert len(response_json['simple_polygons']) == 1
|
||||
assert len(response_json['simple_polygons'][0]) == 110
|
||||
|
||||
assert response_json['simple_polygons'][0][0] == [54.419546, -2.988521]
|
||||
assert response_json['simple_polygons'][0][-1] == [54.419546, -2.988521]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("training_mode_service", [True, False])
|
||||
def test_valid_post_cap_xml_broadcast_sets_stubbed_to_true_for_training_mode_services(
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user