예제 #1
0
 def test_delete_ref_presence(self):
     test_entity_id = random.randint(1, MAX_ENTITY_NUM)
     test_entity_ref_id = Operator.get_by_id(Employee,
                                             test_entity_id).department_id
     Operator.remove(Employee, test_entity_id)
     self.assertIsNotNone(Operator.get_by_id(Department,
                                             test_entity_ref_id))
예제 #2
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))
예제 #3
0
    def get(self, id_):
        """Gets a department from the database by the id.

        Returns:
            Retreived department using marshal or
            aborts with 404 if department was not present.
        """

        entity = Operator.get_by_id(Department, id_)
        return entity if entity else abort(404)
예제 #4
0
    def get(self, id_):
        """Gets an employee from the database by the id.

        Returns:
            Retreived employee using marshal or
            aborts with 404 code.
        """

        entity = Operator.get_by_id(Employee, id_)
        return entity if entity else abort(404)
예제 #5
0
 def test_insert(self):
     test_entity = Employee.random()
     test_entity_id = Operator.insert(test_entity)
     self.assertEqual(test_entity,
                      Operator.get_by_id(Employee, test_entity_id))
예제 #6
0
 def test_get(self):
     test_entity_id = random.randint(1, MAX_ENTITY_NUM)
     self.assertIsNotNone(Operator.get_by_id(Employee, test_entity_id))
예제 #7
0
 def test_delete_refs_presence(self):
     test_entity_id = Operator.get_by_id(
         Employee, random.randint(1, MAX_ENTITY_NUM)).department_id
     Operator.remove(Department, test_entity_id)
     self.assertFalse(
         Employee.query.filter_by(department_id=test_entity_id).all())
예제 #8
0
 def test_delete_instance_presence(self):
     test_entity_id = random.randint(1, MAX_ENTITY_NUM)
     Operator.remove(Department, test_entity_id)
     self.assertIsNone(Operator.get_by_id(Department, test_entity_id))
예제 #9
0
 def test_insert(self):
     test_entity = Department.random()
     test_entity_id = Operator.insert(test_entity)
     self.assertEqual(test_entity,
                      Operator.get_by_id(Department, test_entity_id))