def test_can_be_joined4(self): workshifts_data = [{'id': 4, 'total_workshift_days': 8}] workshifts = create_proxy_workshifts(workshifts_data) workshift_db = WorkShiftDB(workshifts, WorkShiftProxy) data = { 'assignation': { 'starting_date': '2019-1-1', 'ending_date': '2019-1-5', 'workshift_id': 4, 'person_id': 1, 'starting_day': 6 } } assign1 = create_an_assignation(data, workshift_db) data = { 'assignation': { 'starting_date': '2019-1-7', 'ending_date': '2019-1-11', 'workshift_id': 4, 'person_id': 1, 'starting_day': 4 } } assign2 = create_an_assignation(data, workshift_db) data = { 'assignation': { 'starting_date': '2018-12-31', 'ending_date': '2019-1-8', 'workshift_id': 4, 'person_id': 1, 'starting_day': 5 } } assign = create_an_assignation(data, workshift_db) list_assigns = [assign1, assign2] resp = AssignationOperator.are_multiple_compatible( assign, list_assigns) assert resp == list_assigns
def unassign(self, fake_assign: AssignationProxy) -> None: """ The main method to unassign. In this case, the fake_assign is just an AssignationMaper that represent the attributes of the range to remove in a specific workshift of a person """ db_assigns = self.get_assigns(fake_assign) compatibe_assigns = AssignationOperator.are_multiple_compatible( fake_assign, db_assigns) for compatibe_assign in compatibe_assigns: resp = AssignationOperator.remove( compatibe_assign, fake_assign.range_obj.starting_date, fake_assign.range_obj.ending_date) if resp['update']: self.update(resp['update']) if resp['create']: self.add(resp['create']) if resp['delete']: self.remove(resp['delete'])