def test_deallocate_invalid_3(calendar: services.InterviewCalendar, test_data_set_1): # Remove invalid user time_frame = (datetime(2018, 7, 10), datetime(2018, 7, 11)) calendar.deallocate('User 3', services.UserType.Interviewer, time_frame) results = list(calendar.query()) assert len(results) == 12
def test_deallocate_valid_1(calendar: services.InterviewCalendar, test_data_set_1): # Remove valid time frame from User 1 time_frame = (datetime(2018, 7, 10, 12), datetime(2018, 7, 10, 16)) calendar.deallocate('User 1', services.UserType.Interviewer, time_frame) results = list(calendar.query('User 1')) assert len(results) == 4
def test_query_by_user_type_1(calendar: services.InterviewCalendar, test_data_set_1): interviews = list(calendar.query(user_type=services.UserType.Interviewer)) assert len(interviews) == 8 candidates = list(calendar.query(user_type=services.UserType.Candidate)) assert len(candidates) == 4
def test_deallocate_invalid_2(calendar: services.InterviewCalendar, test_data_set_1): # Remove valid user with invalid type time_frame = (datetime(2018, 7, 10), datetime(2018, 7, 11)) calendar.deallocate('User 1', services.UserType.Candidate, time_frame) results = list(calendar.query('User 1')) assert len(results) == 8
def test_allocate_1(calendar: services.InterviewCalendar): begin = datetime(2018, 7, 10, 13) end = datetime(2018, 7, 10, 15) allocated = calendar.allocate('User 1', services.UserType.Candidate, (begin, end)) assert len(allocated) == 2 mid = begin + timedelta(hours=1) assert allocated[0] == services.InterviewSchedule( 'User 1', services.UserType.Candidate, begin, mid) assert allocated[1] == services.InterviewSchedule( 'User 1', services.UserType.Candidate, mid, end)
def get_interview_calendar(): if 'interview_calendar' not in g: name_constraints = [constraints.long_name] time_frame_constraints = [ constraints.time_frame_sanity, constraints.time_frame_weekdays, constraints.time_frame_hour ] g.interview_calendar = InterviewCalendar( name_constraints=name_constraints, time_frame_constraints=time_frame_constraints) return g.interview_calendar
def test_query_by_name_2(calendar: services.InterviewCalendar, test_data_set_1): results = list(calendar.query('User 2')) assert len(results) == 4
def test_query_by_time_frame_3(calendar: services.InterviewCalendar, test_data_set_1): # This is intersection time frame for both type of users time_frame = (datetime(2018, 7, 10, 13), datetime(2018, 7, 10, 16)) results = list(calendar.query(time_frame=time_frame)) assert len(results) == 3 * 2
def test_query_by_time_frame_2(calendar: services.InterviewCalendar, test_data_set_1): # This is available for candidate only time_frame = (datetime(2018, 7, 10, 16), datetime(2018, 7, 10, 20)) results = list(calendar.query(time_frame=time_frame)) assert len(results) == 1
def test_query_1(calendar: services.InterviewCalendar, test_data_set_1): all_ = list(calendar.query()) assert len(all_) == 12
def test_deallocate_valid_2(calendar: services.InterviewCalendar, test_data_set_1): time_frame = (datetime(2018, 7, 10, 13), datetime(2018, 7, 10, 17)) calendar.deallocate('User 2', services.UserType.Candidate, time_frame) results = list(calendar.query('User 2')) assert len(results) == 0