예제 #1
0
 def test_update(self):
     test_entity_new = Employee.random()
     test_entity_new.id = random.randint(1, MAX_ENTITY_NUM)
     Operator.update(Employee, marsh(test_entity_new, EmployeeSchema))
     self.assertEqual(
         marsh(test_entity_new, EmployeeSchema),
         marsh(Operator.get_by_id(Employee, test_entity_new.id),
               EmployeeSchema))
예제 #2
0
    def test_update(self):
        test_entity_new = Department.random()
        test_entity_new.id = random.randint(1, MAX_ENTITY_NUM)

        self.assertTrue(
            Operator.update(Department,
                            marsh(vars(test_entity_new), DepartmentSchema)))
예제 #3
0
    def put(self, id_):
        """Updates a department from the database by the id.

        Returns:
            True (if the operation was successful)
            or False using marshal or aborts with
            code 400.
        """

        try:
            raw_data = lomarsh(request.form, DepartmentSchema)
            raw_data['id'] = id_
            return Operator.update(Department, raw_data)
        except (IntegrityError, ValidationError):
            abort(400)
예제 #4
0
    def put(self, id_):
        """Updates an employee from the database by the id.

        Returns:
            True (if the operation was successful)
            or False using marshal or aborts
            with 400 code.
        """

        try:
            raw_data = lomarsh(request.form, EmployeeSchema)
            raw_data['id'] = id_
            return Operator.update(Employee, raw_data)
        except (IntegrityError, InternalError, ValidationError):
            abort(400)