def step_impl(context): # smazani bylo uspesne assert context.resp.status_code == status.HTTP_204_NO_CONTENT assert not helpers.find_attendancestate_with_name(context.api_client, context.name) assert attendancestates_cnt( context.api_client) < context.old_attendancestates_cnt
def attendance_dict(api_client, client, attendancestate, paid, note): return { "client_id": helpers.find_client_with_full_name(api_client, client), "attendancestate": helpers.find_attendancestate_with_name(api_client, attendancestate), "paid": common_helpers.to_bool(paid), "note": note, }
def step_impl(context, name): # nacti jmeno stavu ucasti do kontextu load_id_data_to_context(context, name) # najdi stav ucasti attendancestate_to_delete = helpers.find_attendancestate_with_name( context.api_client, context.name) assert attendancestate_to_delete # uloz puvodni pocet stavu ucasti save_old_attendancestates_cnt_to_context(context) # smazani stavu ucasti context.resp = context.api_client.delete( f"{helpers.API_ATTENDANCESTATES}{attendancestate_to_delete['id']}/")
def step_impl(context, cur_name, new_name, new_visible): # nacteni dat stavu ucasti do kontextu load_data_to_context(context, new_name, new_visible) # najdi stav ucasti attendancestate_to_update = helpers.find_attendancestate_with_name( context.api_client, cur_name) assert attendancestate_to_update # uloz puvodni pocet stavu ucasti save_old_attendancestates_cnt_to_context(context) # vlozeni stavu ucasti context.resp = context.api_client.put( f"{helpers.API_ATTENDANCESTATES}{attendancestate_to_update['id']}/", attendancestate_dict(context), )
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)