-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1019 from uktrade/release
Prod Release 2.3.2
- Loading branch information
Showing
7 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import re | ||
|
||
from django.core.exceptions import ValidationError | ||
|
||
|
||
def validate_lat_long(value): | ||
if re.match(r'^(-|\+)?\d{1,3}(\.\d+)?\s*,\s*(-|\+)?\d{1,3}(\.\d+)?$', value.strip()) is None: | ||
raise ValidationError('Invalid latitude/longitude.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
django==2.2.26 | ||
django==2.2.28 | ||
djangorestframework==3.12.* | ||
django-environ==0.4.5 | ||
gunicorn==20.1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
from django.core.exceptions import ValidationError | ||
|
||
from great_international.validators import validate_lat_long | ||
|
||
|
||
@pytest.mark.django_db | ||
@pytest.mark.parametrize( | ||
'value, raise_expected', | ||
( | ||
('51.123456, -2.345678', False), | ||
(' 51.123456 , -2.345678 ', False), | ||
('+51.123456, +1.1', False), | ||
(' 51.123456, -2.345678 ', False), | ||
('31.123456,2.345678', False), | ||
('50, 2', False), | ||
('50., 2.', True), | ||
('50', True), | ||
('50º N, 2º W', True), | ||
('Not even trying', True), | ||
) | ||
) | ||
def test_validate_lat_long(value, raise_expected): | ||
try: | ||
validate_lat_long(value) | ||
except ValidationError: | ||
if not raise_expected: | ||
pytest.fail(f'Expected {value} to pass validation, but it failed') | ||
else: | ||
if raise_expected: | ||
pytest.fail(f'Expected {value} to fail validation, but it passed') |