독한 it

  • 홈
  • 태그
  • 방명록
독하게 한다면 뭐든 할 수 있다.

전체 글 138

POST API

# request.pyfrom pydantic import BaseModelclass CreateToDoRequest(BaseModel): contents: str is_done: bool# main.py@app.post("/todos", status_code=201)# FastAPI가 알아서 reqeustBody를 CreateToDoRequest에 넣어서 처리를 해준다.def create_todo_handler( request: CreateToDoRequest, session: Session = Depends(get_db)) -> ToDoSchema: todo: ToDo=ToDo.create(request=request) # id=None todo: ToD..

FastAPI/테스트 코드 2026.07.10

GET 단일 조회 API

# main.py@app.get("/todos/{todo_id}", status_code=200)def get_todo_handler( todo_id: int, session: Session = Depends(get_db),) -> ToDoSchema: todo: ToDo | None = get_todo_by_todo_id(session=session, todo_id=todo_id) if todo: return ToDoSchema.model_validate(todo) # 만약 todo가 없다면 raise HTTPException(status_code=404, detail="ToDo Not Found") # test_main.pydef tes..

FastAPI/테스트 코드 2026.07.07

PyTest Fixture

def test_get_todos(mocker): # order = ASC # mocker를 쓰며 실제로 이 함수를 동작시키는 것이 아니라 이 함수가 동작한 것처럼 속이겠다 라는 의미 # 그래서 DB에 들리지 않고 그냥 밑의 return_value 값으로 반환이 돼어 테스트하게 된다. mocker.patch("main.get_todos", return_value=[ ToDo(id=1, contents="FastAPI Section 0", is_done=True), ToDo(id=2, contents="FastAPI Section 1", is_done=False), ]) response = client.get("/todos") assert re..

FastAPI/테스트 코드 2026.07.07
이전
1 2 3 4 ··· 46
다음
더보기
프로필사진

독한 it

독하게 한다면 뭐든 할 수 있다.

  • 분류 전체보기 (138) N
    • 파이썬 (59)
      • 자료형 (2)
      • 연산자 (4)
      • 문자열 처리 (10)
      • 자료구조 (7)
      • 제어문 (5)
      • 함수 (6)
      • 입출력 (7)
      • 클래스 (9)
      • 예외처리 (4)
      • 모듈과 패키지 (5)
    • 브리티웍스 (0)
      • 교육 (0)
      • 배운 것 (0)
    • 기록장 (0)
    • 네트워크 (1)
    • 통신 (3)
    • 머신러닝 (34)
      • 개념 (5)
      • 머신러닝, 데이터 분석 도구 (5)
      • scikit-learn & 첫 머신러닝 모델 (4)
      • Kaggle 입문 - 타이타닉 승객 생존자 예측 (5)
      • Ridge, Lasso, ElasticNet 알고.. (7)
      • Random Forest & 머신러닝 모델 (6)
      • XGBoost 알고리즘 (2)
    • 알고리즘 (9)
      • 백준(파이썬) (6)
      • 에러 (2)
      • DP (동적 프로그래밍) (1)
    • FastAPI (28) N
      • FastAPI 알아보기 (8)
      • 데이터베이스 (13)
      • 테스트 코드 (7) N
    • AI (3)
    • 지능형 (0)
    • 인프라 (1)
      • Docker (1)

Tag

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2026/07   »
일 월 화 수 목 금 토
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © AXZ Corp. All rights reserved.

티스토리툴바