2015-09-01 03:31:25 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.core import management
|
2015-09-08 17:09:03 +00:00
|
|
|
from tracking.models import Track
|
2015-09-01 03:31:25 +00:00
|
|
|
from django.core.management.base import CommandError
|
|
|
|
|
|
|
|
# Create your tests here.
|
|
|
|
class ImportGPXManagementTest(TestCase):
|
|
|
|
fixtures = ['tracking_test_fixtures.json',]
|
2015-09-07 18:29:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.example_ride_file = "testing/example-ride.gpx"
|
|
|
|
|
2015-09-01 03:31:25 +00:00
|
|
|
def test_user_does_not_exist(self):
|
|
|
|
with self.assertRaisesMessage(CommandError, "User THISUSERWONTEXIST does not exist"):
|
|
|
|
management.call_command('import_gpx', 'THISUSERWONTEXIST', 'foo')
|
|
|
|
|
|
|
|
def test_path_exists(self):
|
|
|
|
with self.assertRaisesMessage(CommandError, "/noop/nodir/ is neither an existing file, nor a path."):
|
|
|
|
management.call_command('import_gpx', 'tyrel', '/noop/nodir/')
|
|
|
|
|
2015-09-07 18:29:31 +00:00
|
|
|
def test_import(self):
|
2015-09-08 17:09:03 +00:00
|
|
|
track_count = Track.objects.all().count()
|
2015-09-07 18:29:31 +00:00
|
|
|
management.call_command('import_gpx', 'tyrel', 'testing/example-ride.gpx')
|
2015-09-08 17:09:03 +00:00
|
|
|
new_track_count = Track.objects.all().count()
|
|
|
|
self.assertNotEqual(track_count, new_track_count)
|
2015-09-07 18:29:31 +00:00
|
|
|
|
|
|
|
|