예제 #1
0
    def test_get_perc_second_user(self):
        cs = conf.ClimbStatus.climbed.value
        os = conf.ClimbStatus.onsight.value

        sampledata.create_auth_user()  # user_id = 1
        sampledata.create_auth_user(name='me')
        sampledata.add_gym()
        sampledata.route_set_active(colour='blue')  # route_set_id=2
        sampledata.route_set_inactive()  # route_set_id=2

        sampledata.create_sample_route_record(
            route_id=1, record_type=conf.ClimbStatus.onsight.value)
        sampledata.create_sample_route_record(
            route_id=1, record_type=conf.ClimbStatus.attempted.value)
        sampledata.create_sample_route_record(
            route_id=1, record_type=conf.ClimbStatus.climbed.value)
        sampledata.create_sample_route_record(
            route_id=1, record_type=conf.ClimbStatus.onsight.value)
        sampledata.create_sample_route_record(
            route_id=2, record_type=conf.ClimbStatus.attempted.value)
        sampledata.create_sample_route_record(
            user_id=2, route_id=2, record_type=conf.ClimbStatus.climbed.value)
        sampledata.create_sample_route_record(
            user_id=2, route_id=1, record_type=conf.ClimbStatus.climbed.value)

        gym_id = 1
        user_id = 2
        grade = 5

        perc_complete = metrics.get_percentage_complete_for_active_grade(
            gym_id, user_id, grade)
        self.assertEqual(perc_complete, 100)
예제 #2
0
def create_sample_data():
    sampledata.add_gym()
    sampledata.route_set_inactive(colour='yellow')
    sampledata.route_set_active(colour='red')
    sampledata.route_set_active(colour='black')

    sampledata.create_auth_user()
    sampledata.create_sample_route_record()
예제 #3
0
    def test_create_route_set_invalid_gym_id(self):
        sampledata.create_auth_user()
        sampledata.add_gym()

        service_rs.create_route_set(101, self.grade, self.grade_sub,
                                    self.up_date, self.down_date, zone=self.zone)

        self.assertEqual(models.RouteSet.objects.filter(id=1).exists(), False)
예제 #4
0
    def test_create_route_set_grade(self):
        sampledata.create_auth_user()
        sampledata.add_gym()

        service_rs.create_route_set(self.gym_id, self.grade[0], self.grade_sub,
                                    self.up_date, self.down_date, zone=self.zone)
        rs = models.RouteSet.objects.get(id=1)

        r_all = models.Route.objects.all()
        self.assertEqual(r_all[0].grade, self.grade[0])
        self.assertEqual(r_all[1].grade, self.grade[0])
예제 #5
0
    def test_get_total_climbs_for_route(self):

        sampledata.create_auth_user()
        sampledata.add_gym()
        sampledata.route_set_active()
        sampledata.create_sample_route_record()
        sampledata.create_sample_route_record()
        sampledata.create_sample_route_record(
            record_type=conf.ClimbStatus.onsight.value)
        sampledata.create_sample_route_record(
            record_type=conf.ClimbStatus.attempted.value)
        route_id = 1
        n_climbs = metrics.get_total_climbs_for_route(route_id)
        self.assertEqual(n_climbs[0], 3)
예제 #6
0
    def test_get_all_for_route(self):
        route_id = 1

        sampledata.create_auth_user()
        sampledata.add_gym()
        sampledata.route_set_active()
        sampledata.create_sample_route_record()
        sampledata.create_sample_route_record(record_type=2)

        r = rec.record()
        data = r.get_for_route(route_id)
        self.assertEqual(data[0]['username'], 'Chevy Chase')
        self.assertEqual(data[0]['record_type'], 1)
        self.assertEqual(data[0]['record_type_name'], 'climbed')
        self.assertEqual(data[1]['record_type'], 2)
예제 #7
0
    def test_delete_all_for_user(self):
        user_id = 1
        route_id = 1

        sampledata.create_auth_user()
        sampledata.add_gym()
        sampledata.route_set_active()
        sampledata.gym_and_route_set()
        sampledata.create_sample_route_record()
        sampledata.create_sample_route_record(record_type=2)

        query_pre_list = list(models.RouteRecord.objects.all())

        rec.delete_route_record_for_user(user_id, route_id)

        query = models.RouteRecord.objects.all()

        self.assertEqual(query.count(), 0)
        self.assertEqual(len(query_pre_list), 2)