def test_get_userprofile_length_by_foot(self): competition = mommy.make( 'Competition', competition_type='length', competitor_type='single_user', campaign=self.testing_campaign, date_from=datetime.date(2017, 4, 1), date_to=datetime.date(2017, 5, 31), commute_modes=models.CommuteMode.objects.filter( slug__in=('by_foot', )), ) result = results.get_userprofile_length([self.user_attendance], competition) self.assertEquals(result, 1.0)
def test_get_userprofile_length(self): competition = mommy.make( 'Competition', competition_type='length', competitor_type='single_user', campaign=self.testing_campaign, date_from=datetime.date(2017, 4, 3), date_to=datetime.date(2017, 5, 23), commute_modes=models.CommuteMode.objects.filter( slug__in=('bicycle', 'by_foot')), ) result = results.get_userprofile_length([self.user_attendance], competition) self.assertEquals(result, 5.0) util.rebuild_denorm_models([self.user_attendance]) self.user_attendance.refresh_from_db() result = self.user_attendance.trip_length_total self.assertEquals(result, 5.0)
def test_get_userprofile_length_recreational(self): competition = mommy.make( "Competition", competition_type="length", competitor_type="single_user", campaign=self.testing_campaign, date_from=datetime.date(2017, 4, 3), date_to=datetime.date(2017, 5, 23), commute_modes=models.CommuteMode.objects.filter( slug__in=("bicycle", "by_foot")), ) result = results.get_userprofile_length([self.user_attendance], competition, recreational=True) self.assertEqual(result, 8.0) util.rebuild_denorm_models([self.user_attendance]) self.user_attendance.refresh_from_db() result = self.user_attendance.total_trip_length_including_recreational self.assertEqual(result, 8.0)