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)))
def test_update(self): test_entity_new = Department.random() test_entity_new_id = random.randint(1, MAX_ENTITY_NUM) test_entity_new.id = test_entity_new_id self.client.put(f'/departments/{test_entity_new_id}', data=marsh(test_entity_new, DepartmentSchema)) get_response = self.client.get(f'/departments/{test_entity_new_id}') self.assertEqual(marsh(test_entity_new, DepartmentSchema), marsh(get_response.get_json(), DepartmentSchema))
def test_insert(self): test_entity = Department.random() post_response = self.client.post('/departments', data=marsh(test_entity, DepartmentSchema)) test_entity_id = post_response.get_json().get('data') test_entity.id = test_entity_id get_response = self.client.get(f'/departments/{test_entity.id}') get_response_data = get_response.get_json() self.assertEqual(marsh(test_entity, DepartmentSchema), marsh(get_response_data, DepartmentSchema))
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))