def test_remove_from_department(self): person = self.person.serialize() department = self.department.serialize() persons_service.add_to_department(department["id"], person["id"]) persons_service.remove_from_department(department["id"], person["id"]) person = persons_service.get_person(person["id"]) self.assertEqual(len(person["departments"]), 0)
def post(self, person_id): """ Add a user to given department. --- tags: - Persons parameters: - in: path name: person_id required: True schema: type: UUID example: a24a6ea4-ce75-4665-a070-57453082c25 responses: 201: description: User added to given department """ permissions.check_admin_permissions() args = self.get_args( [ ("department_id", None, True), ] ) try: department = tasks_service.get_department(args["department_id"]) except DepartmentNotFoundException: raise WrongParameterException( "Department ID matches no department" ) person = persons_service.add_to_department(department["id"], person_id) return person, 201
def post(self, person_id): permissions.check_admin_permissions() args = self.get_args([ ("department_id", None, True), ]) try: department = tasks_service.get_department(args["department_id"]) except DepartmentNotFoundException: raise WrongParameterException("Department ID matches no department") person = persons_service.add_to_department(department["id"], person_id) return person, 201
def test_multiple_task_assign_artist(self): self.generate_fixture_task() self.generate_fixture_shot_task() self.generate_fixture_user_cg_artist() task_id = str(self.task.id) shot_task_id = str(self.shot_task.id) person_id = str(self.user_cg_artist["id"]) department_id = str(self.department.id) data = {"task_ids": [task_id, shot_task_id]} self.put("/actions/tasks/clear-assignation", data) self.log_in_cg_artist() self.put("/actions/persons/%s/assign" % person_id, data) task = tasks_service.get_task_with_relations(task_id) self.assertEqual(len(task["assignees"]), 0) task = tasks_service.get_task_with_relations(shot_task_id) self.assertEqual(len(task["assignees"]), 0) persons_service.add_to_department(department_id, person_id) self.put("/actions/persons/%s/assign" % person_id, data) task = tasks_service.get_task_with_relations(task_id) self.assertEqual(len(task["assignees"]), 0) task = tasks_service.get_task_with_relations(shot_task_id) self.assertEqual(len(task["assignees"]), 0)
def test_add_to_department(self): person = self.person.serialize() department = self.department.serialize() persons_service.add_to_department(department["id"], person["id"]) person = persons_service.get_person(person["id"]) self.assertEqual(person["departments"][0], department["id"])