Example #1
0
def test_most_steps_one_day_individual_some_data(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1778
        },
        {
            "gargling_id": 2,
            "amount": 1152
        },
        {
            "gargling_id": 3,
            "amount": 638
        },
        {
            "gargling_id": 5,
            "amount": 11
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)
    achv = achievements.extract(
        query=queries.most_steps_one_day_individual,
        conn=conn,
        journey_id=journey_id,
        date=date,
        less_than=None,
    )
    assert achv is None
Example #2
0
def test_most_steps_one_day_individual_tangering(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 17782
        },
        {
            "gargling_id": 2,
            "amount": 1152
        },
        {
            "gargling_id": 3,
            "amount": 17782
        },
        {
            "gargling_id": 5,
            "amount": 11
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 17782
        },
        {
            "gargling_id": 2,
            "amount": 11521
        },
        {
            "gargling_id": 3,
            "amount": 6380
        },
        {
            "gargling_id": 5,
            "amount": 111
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    achv = achievements.extract(
        query=queries.most_steps_one_day_individual,
        conn=conn,
        journey_id=journey_id,
        date=date,
        less_than=None,
    )
    assert achv is not None
    holders, value, prev_holders, prev_value = achv
    assert holders == [6]
    assert value == 17782
    assert prev_holders == {3, 6}
    assert prev_value is None
Example #3
0
def test_most_steps_one_day_collective_new_record(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1778
        },
        {
            "gargling_id": 2,
            "amount": 1152
        },
        {
            "gargling_id": 3,
            "amount": 638
        },
        {
            "gargling_id": 5,
            "amount": 11
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 17782
        },
        {
            "gargling_id": 2,
            "amount": 11521
        },
        {
            "gargling_id": 3,
            "amount": 6380
        },
        {
            "gargling_id": 5,
            "amount": 111
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    achv = achievements.extract(
        query=queries.most_steps_one_day_collective,
        conn=conn,
        journey_id=journey_id,
        date=date,
    )
    assert achv is not None
    holders, value, prev_holders, prev_value = achv
    assert holders is None
    assert value == 35794
    assert prev_holders is None
    assert prev_value == 3579
Example #4
0
def test_highest_share_new_record(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 25
        },
        {
            "gargling_id": 2,
            "amount": 25
        },
        {
            "gargling_id": 3,
            "amount": 30
        },
        {
            "gargling_id": 5,
            "amount": 20
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 5
        },
        {
            "gargling_id": 2,
            "amount": 5
        },
        {
            "gargling_id": 3,
            "amount": 5
        },
        {
            "gargling_id": 5,
            "amount": 85
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    achv = achievements.extract(query=queries.highest_share,
                                conn=conn,
                                journey_id=journey_id,
                                date=date)
    assert achv is not None
    holders, value, prev_holders, prev_value = achv
    assert holders == [5]
    assert value == 85
    assert prev_holders == {3}
    assert prev_value == 30
Example #5
0
def test_most_steps_one_day_individual_no_data(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    achv = achievements.extract(
        query=queries.most_steps_one_day_individual,
        conn=conn,
        journey_id=journey_id,
        date=date,
        less_than=None,
    )
    assert achv is None
Example #6
0
def test_longest_streak_new_record(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    journey.queries.start_journey(conn, journey_id=journey_id, date=date)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1
        },
        {
            "gargling_id": 2,
            "amount": 2000
        },
        {
            "gargling_id": 3,
            "amount": 2000
        },
        {
            "gargling_id": 5,
            "amount": 1
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 2000
        },
        {
            "gargling_id": 2,
            "amount": 2000
        },
        {
            "gargling_id": 3,
            "amount": 1
        },
        {
            "gargling_id": 5,
            "amount": 1
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 2000
        },
        {
            "gargling_id": 2,
            "amount": 1
        },
        {
            "gargling_id": 3,
            "amount": 1
        },
        {
            "gargling_id": 5,
            "amount": 2000
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1
        },
        {
            "gargling_id": 2,
            "amount": 1
        },
        {
            "gargling_id": 3,
            "amount": 1
        },
        {
            "gargling_id": 5,
            "amount": 2000
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)
    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1
        },
        {
            "gargling_id": 2,
            "amount": 1
        },
        {
            "gargling_id": 3,
            "amount": 1
        },
        {
            "gargling_id": 5,
            "amount": 2000
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    achv = achievements.extract(query=queries.longest_streak,
                                conn=conn,
                                journey_id=journey_id,
                                date=date)
    assert achv is not None
    holders, value, prev_holders, prev_value = achv
    assert holders == [5]
    assert value == 3
    assert prev_holders == {2, 5, 6}
    assert prev_value == 2
Example #7
0
def test_biggest_improvement_individual_new_record(conn: connection):
    date = pendulum.Date(2000, 1, 1)
    journey_id = test_journey.insert_journey_data(conn)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 1778
        },
        {
            "gargling_id": 2,
            "amount": 1152
        },
        {
            "gargling_id": 3,
            "amount": 638
        },
        {
            "gargling_id": 5,
            "amount": 11
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 17782
        },
        {
            "gargling_id": 2,
            "amount": 11521
        },
        {
            "gargling_id": 3,
            "amount": 6380
        },
        {
            "gargling_id": 5,
            "amount": 111
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    date = date.add(days=1)
    steps_data = [
        {
            "gargling_id": 6,
            "amount": 7782
        },
        {
            "gargling_id": 2,
            "amount": 1521
        },
        {
            "gargling_id": 3,
            "amount": 380
        },
        {
            "gargling_id": 5,
            "amount": 20111
        },
    ]
    journey.store_steps(conn, steps_data, journey_id, date)

    achv = achievements.extract(
        query=queries.biggest_improvement_individual,
        conn=conn,
        journey_id=journey_id,
        date=date,
    )
    assert achv is not None
    holders, value, prev_holders, prev_value = achv
    assert holders == [5]
    assert value == 20000
    assert prev_holders == {6}
    assert prev_value == 16004