コード例 #1
0
def step_impl(
    context,
    date,
    time,
    new_date,
    new_time,
    new_course,
    new_duration,
    new_canceled,
    client,
    new_attendancestate,
    new_paid,
    new_note,
):
    new_attendances = [
        attendance_dict(context.api_client, client, new_attendancestate,
                        new_paid, new_note)
    ]
    # nacteni dat lekce do kontextu
    load_data_to_context(context, new_course, new_date, new_time, new_duration,
                         new_canceled, new_attendances)
    # najdi lekci
    lecture_to_update = helpers.find_lecture_with_start(
        context.api_client, common_helpers.prepare_start(date, time))
    assert lecture_to_update
    # uloz puvodni pocet lekci
    save_old_lectures_cnt_to_context(context)
    # vlozeni lekce
    context.resp = context.api_client.put(
        f"{helpers.API_LECTURES}{lecture_to_update['id']}/",
        lecture_dict(context, lecture_to_update),
    )
コード例 #2
0
def step_impl(context):
    # uprava byla uspesna
    assert context.resp.status_code == status.HTTP_200_OK
    # nacti udaje upravovane lekce
    lecture_to_update = helpers.find_lecture_with_start(
        context.api_client, context.start)
    assert lecture_to_update
    # ma lekce opravdu nove udaje?
    assert lecture_to_update["attendances"][0]["paid"] == context.new_paid
コード例 #3
0
def step_impl(context, client, date, time):
    # nacti timestamp lekce do kontextu
    load_id_data_to_context(context, date, time)
    # najdi lekci
    lecture_to_delete = helpers.find_lecture_with_start(
        context.api_client, context.start)
    assert lecture_to_delete
    # uloz puvodni pocet lekci
    save_old_lectures_cnt_to_context(context)
    # smazani lekce
    context.resp = context.api_client.delete(
        f"{helpers.API_LECTURES}{lecture_to_delete['id']}/")
コード例 #4
0
def step_impl(context, client, date, time, new_paid):
    # nacteni dat lekce do kontextu
    load_id_data_to_context(context, date, time)
    # najdi lekci
    lecture_to_update = helpers.find_lecture_with_start(
        context.api_client, common_helpers.prepare_start(date, time))
    assert lecture_to_update
    # najdi id attendance
    attendance_id = lecture_to_update["attendances"][0]["id"]
    # vlozeni lekce
    content = attendance_dict_patch(attendance_id, paid=new_paid)
    context.resp = context.api_client.patch(
        f"{helpers.API_ATTENDANCES}{attendance_id}/", content)
    # uloz ocekavany novy stav do kontextu
    context.new_paid = common_helpers.to_bool(new_paid)
コード例 #5
0
def step_impl(context):
    # uprava byla uspesna
    assert context.resp.status_code == status.HTTP_200_OK
    # nacti udaje upravovane lekce
    lecture_to_update = helpers.find_lecture_with_start(
        context.api_client, context.start)
    assert lecture_to_update
    # ma lekce opravdu nove udaje?
    assert (lecture_to_update["attendances"][0]["attendancestate"] ==
            context.new_attendancestate["id"])
    # pokud se lekce nove zmenila na omluvenou a byla zaplacena, over pridani nahradni lekce
    excused_attendancestate = common_helpers.get_excused_attendancestate()
    if (context.cur_attendancestate["name"] != excused_attendancestate
            and context.new_attendancestate["name"] == excused_attendancestate
            and lecture_to_update["attendances"][0]["paid"]):
        assert lectures_cnt(context.api_client) == context.old_lectures_cnt + 1
    else:
        assert lectures_cnt(context.api_client) == context.old_lectures_cnt
コード例 #6
0
def step_impl(context, client, date, time, new_attendancestate):
    new_attendancestate = helpers.find_attendancestate_with_name(
        context.api_client, new_attendancestate)
    # nacteni dat lekce do kontextu
    load_id_data_to_context(context, date, time)
    # najdi lekci
    lecture_to_update = helpers.find_lecture_with_start(
        context.api_client, common_helpers.prepare_start(date, time))
    assert lecture_to_update
    # najdi id attendance
    attendance_id = lecture_to_update["attendances"][0]["id"]
    attendancestate_id = lecture_to_update["attendances"][0]["attendancestate"]
    # uloz puvodni pocet lekci
    save_old_lectures_cnt_to_context(context)
    # vlozeni lekce
    content = attendance_dict_patch(attendance_id,
                                    attendancestate=new_attendancestate["id"])
    context.resp = context.api_client.patch(
        f"{helpers.API_ATTENDANCES}{attendance_id}/", content)
    # uloz ocekavany novy a aktualni stav do kontextu
    context.new_attendancestate = new_attendancestate
    context.cur_attendancestate = helpers.find_attendancestate_with_id(
        context.api_client, attendancestate_id)
コード例 #7
0
def step_impl(context):
    # smazani bylo uspesne
    assert context.resp.status_code == status.HTTP_204_NO_CONTENT
    assert not helpers.find_lecture_with_start(context.api_client,
                                               context.start)
    assert lectures_cnt(context.api_client) < context.old_lectures_cnt