예제 #1
0
    def test_upload_gpx_creates_trackpoints(self):
        with self.settings(MEDIA_ROOT=self.temp_dir):
            test_file = SimpleUploadedFile('test1.gpx', GPX_BIN)
            assert len(ActivityTrackpoint.objects.all()) == 0

            ActivityTrack.create_new(
                upfile=test_file,
                activity=Activity.objects.create(user=UserFactory.create()))
            assert len(ActivityTrackpoint.objects.all()) == 5

            first = ActivityTrackpoint.objects.first()
            last = ActivityTrackpoint.objects.last()

            assert my_round(first.lat) == 43.078
            assert my_round(first.lon) == -89.384
            assert first.sog == 0.0
            assert first.timepoint.month == 3
            assert first.timepoint.day == 16
            assert first.timepoint.hour == 17
            assert first.timepoint.second == 56

            assert my_round(last.lat) == 43.074
            assert my_round(last.lon) == -89.380
            assert my_round(last.sog) == 2.847
            assert last.timepoint.month == 3
            assert last.timepoint.day == 16
            assert last.timepoint.hour == 17
            assert last.timepoint.second == 57
예제 #2
0
    def test_upload_sbn_creates_trackpoints(self):
        with self.settings(MEDIA_ROOT=self.temp_dir):
            test_file = SimpleUploadedFile('test1.sbn', SBN_BIN)
            assert 0 == len(ActivityTrackpoint.objects.all())

            ActivityTrack.create_new(
                upfile=test_file,
                activity=Activity.objects.create(user=UserFactory.create()))

            assert 4 == len(ActivityTrackpoint.objects.all())

            first = ActivityTrackpoint.objects.first()
            last = ActivityTrackpoint.objects.last()

            assert my_round(first.lat) == 43.087
            assert my_round(first.lon) == -89.389
            assert my_round(first.sog) == 3.11
            assert first.timepoint.month == 7
            assert first.timepoint.day == 15
            assert first.timepoint.hour == 22
            assert first.timepoint.second == 54
            assert my_round(last.lat) == 43.087
            assert my_round(last.lon) == -89.389
            assert my_round(last.sog) == 3.420
            assert last.timepoint.month == 7
            assert last.timepoint.day == 15
            assert last.timepoint.hour == 22
            assert last.timepoint.second == 57
예제 #3
0
    def test_home_page_does_not_show_activities_without_details(self):
        with self.settings(MEDIA_ROOT=self.temp_dir):
            a = Activity.objects.create(user=UserFactory.create())
            ActivityTrack.create_new(upfile=SimpleUploadedFile(
                'test1.sbn', SBN_BIN),
                                     activity=a)

            response = self.client.get(reverse('home'))
            self.assertNotContains(response, '></a>')
예제 #4
0
 def setUp(self):
     super(TestActivityModelIntegration, self).setUp()
     with self.settings(MEDIA_ROOT=self.temp_dir):
         a = ActivityTrack.create_new(activity=ActivityFactory.create(),
                                      upfile=SimpleUploadedFile(
                                          "test1.SBN", SBN_BIN))
     self.activity = a.activity  # type: Activity
     self.activity.compute_stats()
예제 #5
0
    def test_model_ordering_on_dates_with_most_last_first(self):
        with self.settings(MEDIA_ROOT=self.temp_dir):
            files = ['test{}.sbn'.format(x) for x in [1, 2, 3]]
            hours = [11, 10, 12]
            test_files = []
            for f, t in zip(files, hours):
                test_files.append(SimpleUploadedFile(f, SBN_BIN))
                a = ActivityTrack.create_new(test_files[-1],
                                             ActivityFactory.create())

                a.trim_start = datetime(2014,
                                        10,
                                        12,
                                        t,
                                        20,
                                        15,
                                        tzinfo=timezone('UTC'))
                a.save()

            activities = ActivityTrack.objects.all()
            assert 'test3.sbn' == activities[2].original_filename
            assert 'test1.sbn' == activities[1].original_filename
            assert 'test2.sbn' == activities[0].original_filename
예제 #6
0
 def make_track():
     with self.settings(MEDIA_ROOT=self.temp_dir):
         self.track = ActivityTrack.create_new(
             activity=ActivityFactory.create(),
             upfile=SimpleUploadedFile("test1.SBN", SBN_BIN))