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))
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))
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)
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)
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))
def test_get(self): test_entity_id = random.randint(1, MAX_ENTITY_NUM) self.assertIsNotNone(Operator.get_by_id(Employee, test_entity_id))
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())
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))
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))