Sure, here are the full codes for the FastAPI app and the tests:

`main.py`:
```python
from typing import List
from fastapi import FastAPI, Depends, HTTPException
from sqlalchemy.orm import Session
from database import SessionLocal, engine
from models import User, Group, UserInGroup, Base

Base.metadata.create_all(bind=engine)

app = FastAPI()

# Dependency
def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()

@app.post("/users/", response_model=User)
def create_user(user: User, db: Session = Depends(get_db)):
    db_user = User(name=user.name, email=user.email)
    db.add(db_user)
    db.commit()
    db.refresh(db_user)
    return db_user

@app.get("/users/", response_model=List[User])
def read_users(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
    users = db.query(User).offset(skip).limit(limit).all()
    return users

@app.get("/users/{user_id}", response_model=User)
def read_user(user_id: int, db: Session = Depends(get_db)):
    db_user = db.query(User).filter(User.id == user_id).first()
    if db_user is None:
        raise HTTPException(status_code=404, detail="User not found")
    return db_user

@app.post("/groups/", response_model=Group)
def create_group(group: Group, db: Session = Depends(get_db)):
    db_group = Group(name=group.name)
    db.add(db_group)
    db.commit()
    db.refresh(db_group)
    return db_group

@app.post("/groups/{group_id}/users/", response_model=UserInGroup)
def add_user_to_group(group_id: int, user_id: int, db: Session = Depends(get_db)):
    db_group = db.query(Group).filter(Group.id == group_id).first()
    db_user = db.query(User).filter(User.id == user_id).first()
    if db_group is None:
        raise HTTPException(status_code=404, detail="Group not found")
    if db_user is None:
        raise HTTPException(status_code=404, detail="User not found")
    user_in_group = UserInGroup(user_id=user_id, group_id=group_id)
    db.add(user_in_group)
    db.commit()
    db.refresh(user_in_group)
    return user_in_group

@app.get("/groups/{group_id}/users/", response_model=List[User])
def get_users_in_group(group_id: int, db: Session = Depends(get_db)):
    db_group = db.query(Group).filter(Group.id == group_id).first()
    if db_group is None:
        raise HTTPException(status_code=404, detail="Group not found")
    users = db.query(User).join(UserInGroup).filter(UserInGroup.group_id == group_id).all()
    return users

@app.delete("/groups/{group_id}/users/{user_id}")
def delete_user_from_group(group_id: int, user_id: int, db: Session = Depends(get_db)):
    db_group = db.query(Group).filter(Group.id == group_id).first()
    db_user = db.query(User).filter(User.id == user_id).first()
    if db_group is None:
        raise HTTPException(status_code=404, detail="Group not found")
    if db_user is None:
        raise HTTPException(status_code=404, detail="User not found")
    user_in_group = db.query(UserInGroup).filter(UserInGroup.group_id == group_id, UserInGroup.user_id == user_id).first()
    if user_in_group is None:
```
물론 다음은 FastAPI 앱과 테스트에 대한 전체 코드입니다:`main.py`:```python에서 임포트 목록from fastapi import FastAPI, Depends, HTTPExceptionsqlalchemy.orm에서 Session을 가져옵니다.데이터베이스에서 세션 로컬, 엔진모델에서 사용자, 그룹, 사용자인그룹, 베이스 가져오기Base.metadata.create_all(바인드=엔진)app = FastAPI()# 의존성def get_db():    db = 세션로컬()    try:        yield db    마지막으로        db.close()app.post("/users/", response_model=User)def create_user(user: User, db: 세션 = Depends(get_db)):    db_user = 사용자(이름=사용자.이름, 이메일=사용자.이메일)    db.add(db_user)    db.commit()    db.refresh(db_user)    반환 db_user@app.get("/users/", response_model=List[User])def read_users(skip: int = 0, limit: int = 100, db: 세션 = Depends(get_db)):    users = db.query(User).offset(skip).limit(limit).all()    사용자 반환@app.get("/users/{user_id}", response_model=User)def read_user(user_id: int, db: 세션 = Depends(get_db)):    db_user = db.query(User).filter(User.id == user_id).first()    db_user가 None이면        HTTPException(status_code=404, detail="사용자를 찾을 수 없음") 발생    db_user 반환@app.post("/groups/", response_model=Group)def create_group(group: Group, db: 세션 = Depends(get_db)):    db_group = 그룹(이름=그룹.이름)    db.add(db_group)    db.commit()    db.refresh(db_group)    반환 db_groupapp.post("/groups/{group_id}/users/", response_model=UserInGroup)def add_user_to_group(group_id: int, user_id: int, db: 세션 = Depends(get_db)):    db_group = db.query(Group).filter(Group.id == group_id).first()    db_user = db.query(User).filter(User.id == user_id).first()    db_group이 None이면        HTTPException(status_code=404, detail="그룹을 찾을 수 없음") 발생    db_user가 None이면        raise HTTPException(status_code=404, detail="사용자를 찾을 수 없음")    user_in_group = UserInGroup(user_id=user_id, group_id=group_id)    db.add(user_in_group)    db.commit()    db.refresh(user_in_group)    반환 사용자_인_그룹app.get("/groups/{group_id}/users/", response_model=List[User])def get_users_in_group(group_id: int, db: 세션 = Depends(get_db)):    db_group = db.query(Group).filter(Group.id == group_id).first()    db_group이 None이면        HTTPException(status_code=404, detail="그룹을 찾을 수 없음") 발생    users = db.query(User).join(UserInGroup).filter(UserInGroup.group_id == group_id).all()    사용자 반환app.delete("/groups/{group_id}/users/{user_id}")def delete_user_from_group(group_id: int, user_id: int, db: 세션 = Depends(get_db)):    db_group = db.query(Group).filter(Group.id == group_id).first()    db_user = db.query(User).filter(User.id == user_id).first()    db_group이 None이면        HTTPException(status_code=404, detail="그룹을 찾을 수 없음") 발생    db_user가 None이면        raise HTTPException(status_code=404, detail="사용자를 찾을 수 없음")    user_in_group = db.query(UserInGroup).filter(UserInGroup.group_id == group_id, UserInGroup.user_id == user_id).first()    사용자_인_그룹이 None인 경우:```