def test_update(db: Session) -> TrackModel: name = random_lower_string() description = random_lower_string() item_in = TrackCreate(name=name, description=description) create(db_session=db, obj_in=item_in) item_update = TrackUpdate(name=random_lower_string(), description=random_lower_string()) updated_track = update(db_session=db, track_name=name, obj_in=item_update) assert updated_track.name == item_update.name assert updated_track.description == item_update.description
def test_create_duplicate_item(db: Session) -> TrackModel: name = random_lower_string() description = random_lower_string() item_in = TrackCreate(name=name, description=description) item = create(db_session=db, obj_in=item_in) assert item.name == name assert item.description == description assert item.id is not None with pytest.raises(ExistenceException): create(db_session=db, obj_in=item_in)
def create_track(*, db: Session = Depends(get_db), track_in: TrackCreate): """ Inserts a track into the Track table, given the request body. """ try: created_Track = create(db_session=db, obj_in=track_in) except ExistenceException as err: raise HTTPException(status_code=303, detail=err.message) return created_Track
def test_read_one(db: Session) -> TrackModel: name = random_lower_string() description = random_lower_string() item_in = TrackCreate(name=name, description=description) item = create(db_session=db, obj_in=item_in) item_name = item.name read_item = read_one_by_name(db_session=db, Track_name=item_name) assert read_item.description == description
def test_create_item(db: Session) -> TrackModel: name = random_lower_string() description = random_lower_string() item_in = TrackCreate(name=name, description=description) item = create(db_session=db, obj_in=item_in) assert item.name == name assert item.description == description assert item.id is not None
def test_delete(db: Session) -> TrackModel: name = random_lower_string() description = random_lower_string() item_in = TrackCreate(name=name, description=description) item = create(db_session=db, obj_in=item_in) item_name = item.name delete_item = delete(db_session=db, track_name=item_name) assert delete_item.name == name