From efa602fc31d48594ffa8ca80744cff9ea84d9749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Mon, 8 Feb 2016 15:07:01 +0100 Subject: [PATCH] fix testing --- .travis.yml | 1 - django_gpxpy/gpx_parse.py | 2 +- setup.py | 2 +- tests/test.py | 11 ++++++++++- tests/test_data/test_bad_file.gpx | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 tests/test_data/test_bad_file.gpx diff --git a/.travis.yml b/.travis.yml index b462f07..4a85634 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ script: - coverage run manage.py test python: - - "2.6" - "2.7" - "3.4" - "3.5" diff --git a/django_gpxpy/gpx_parse.py b/django_gpxpy/gpx_parse.py index d13e2ca..0a94551 100644 --- a/django_gpxpy/gpx_parse.py +++ b/django_gpxpy/gpx_parse.py @@ -40,6 +40,6 @@ def parse_gpx(track): if len(track_list_of_points) > 1: multiline.append(LineString(track_list_of_points)) return MultiLineString(multiline) - except gpxpy.GPXException as e: + except gpxpy.gpx.GPXException as e: logger.error("Valid GPX file: %s" % e) raise ValidationError(u"VadnĂ˝ GPX soubor: %s" % e) diff --git a/setup.py b/setup.py index ebb3fe9..652b453 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ 'gpxpy', ], classifiers=[ - "Development Status :: 1 - Pre-Alpha", + "Development Status :: 2 - Pre-Alpha", "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: System Administrators", diff --git a/tests/test.py b/tests/test.py index d5fd3c7..1714f67 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,11 +1,20 @@ from django_gpxpy.gpx_parse import parse_gpx from django.test import TestCase +from django.core.exceptions import ValidationError class DjangoGpxPyTests(TestCase): - def test_admin_filter_RelatedFieldRadioFilter(self): + def test_gpx_parsing(self): """ test if the admin page with RelatedFieldRadioFilter filters loads succesfully """ with open("tests/test_data/test_track.gpx", "r") as f: multilinestring = parse_gpx(f) self.assertEquals(multilinestring.num_geom, 26) + + def test_bad_file_parsing(self): + """ + test if the admin page with RelatedFieldRadioFilter filters loads succesfully + """ + with self.assertRaises(ValidationError): + with open("tests/test_data/test_bad_file.gpx", "r") as f: + multilinestring = parse_gpx(f) diff --git a/tests/test_data/test_bad_file.gpx b/tests/test_data/test_bad_file.gpx new file mode 100644 index 0000000..d0759c0 --- /dev/null +++ b/tests/test_data/test_bad_file.gpx @@ -0,0 +1 @@ +