def test_delete_position(self): """ Tests that a position is delete from a organization :return: """ pos = org_utils.get_position(1).id assert pos is not None org_utils.deletepositions(pos) pos2 = org_utils.get_position(1) assert pos2 is None
def test_get_postion(self): """ Tests getting a position by ID :return: """ position = org_utils.get_position(1) assert position is not None assert position.id == self.position.id assert position.title == self.position.title position = org_utils.get_position(3) assert position is None
def test_create_single_shift_empty_repeating_key_JSON(self): """ Tests when an empty repeating list is given to the create shift JSON function :return: """ pos = org_utils.get_position(1) shift_dict = { 'position_id': pos.id, 'assigned_user_id': self.john.id, 'start_time': '2016-10-26T08:00:00', 'end_time': '2016-10-26T09:00:00', 'description': 'desc', 'repeating': [] } new_shifts = org_utils.create_shifts_JSON(shift_dict) new_shifts.sort( key=lambda shift: shift.start_time) # sort list by start_time assert new_shifts is not None # print len(new_shifts) assert len(new_shifts) == 1 for s in new_shifts: assert s.position_id == shift_dict['position_id'] assert s.assigned_user_id == shift_dict['assigned_user_id'] assert s.description == shift_dict['description'] # print new_shifts[0].start_time assert new_shifts[0].start_time == '2016-10-26T08:00:00' assert new_shifts[0].end_time == '2016-10-26T09:00:00'
def test_create_single_shift_not_assigned_JSON(self): """ Tests creating a single shift with no repetition from JSON with null user id :return: """ pos = org_utils.get_position(1) shift_dict = { 'position_id': pos.id, 'assigned_user_id': None, 'start_time': '2016-10-26T08:00:00', 'end_time': '2016-10-26T09:00:00', 'description': 'desc', } new_shifts = org_utils.create_shifts_JSON(shift_dict) new_shifts.sort( key=lambda shift: shift.start_time) # sort list by start_time assert new_shifts is not None # print len(new_shifts) assert len(new_shifts) == 1 for s in new_shifts: assert s.position_id == shift_dict['position_id'] assert s.assigned_user_id == shift_dict['assigned_user_id'] assert s.description == shift_dict['description'] # print new_shifts[0].start_time assert new_shifts[0].start_time == '2016-10-26T08:00:00' assert new_shifts[0].end_time == '2016-10-26T09:00:00'
def test_create_position(self): """ Tests that a position is delete from a organization :return: """ pos = org_utils.get_position(1) org = org_utils.get_organization(1) assert pos is not None
def test_assign_member_to_position(self): """ Tests that a user is assigned to a position :return: """ pos = org_utils.get_position(1).id user = org_utils.get_user(1).id org_utils.assign_member_to_position(user, pos) assigneduser = position_assignments.select(position_assignments.c.user_id == 1) assert assigneduser is not None
def test_create_repeating_shifts_diff_days_in_repeating_JSON(self): """ Tests creating a new shift from a dictionary (or JSON) where the repeating list contains days different from the base day :return: """ pos = org_utils.get_position(1) shift_dict = { 'position_id': pos.id, 'assigned_user_id': self.john.id, 'start_time': '2016-10-26T08:00:00', # base day is Wed, day_int = 2 'end_time': '2016-10-26T09:00:00', 'description': 'desc', 'repeating': [1, 3] } # day_int = 2 not present new_shifts = org_utils.create_shifts_JSON(shift_dict) new_shifts.sort( key=lambda shift: shift.start_time) # sort list by start_time assert new_shifts is not None # print len(new_shifts) assert len(new_shifts) == 9 # 1 shift for base day, # 4 shifts per day in 'repeating' for s in new_shifts: assert s.position_id == shift_dict['position_id'] assert s.assigned_user_id == shift_dict['assigned_user_id'] assert s.description == shift_dict['description'] assert new_shifts[0].start_time == '2016-10-25T08:00:00' assert new_shifts[1].start_time == '2016-10-26T08:00:00' assert new_shifts[2].start_time == '2016-10-27T08:00:00' assert new_shifts[3].start_time == '2016-11-01T08:00:00' assert new_shifts[4].start_time == '2016-11-03T08:00:00' assert new_shifts[5].start_time == '2016-11-08T08:00:00' assert new_shifts[6].start_time == '2016-11-10T08:00:00' assert new_shifts[7].start_time == '2016-11-15T08:00:00' assert new_shifts[8].start_time == '2016-11-17T08:00:00' assert new_shifts[0].end_time == '2016-10-25T09:00:00' assert new_shifts[1].end_time == '2016-10-26T09:00:00' assert new_shifts[2].end_time == '2016-10-27T09:00:00' assert new_shifts[3].end_time == '2016-11-01T09:00:00' assert new_shifts[4].end_time == '2016-11-03T09:00:00' assert new_shifts[5].end_time == '2016-11-08T09:00:00' assert new_shifts[6].end_time == '2016-11-10T09:00:00' assert new_shifts[7].end_time == '2016-11-15T09:00:00' assert new_shifts[8].end_time == '2016-11-17T09:00:00'