def test_delete_track_automatically_removes_thumbnail_file(app, example_users): track = Track(id=1, thumbnail=str(uuid4())) db.session.add(track) db.session.commit() create_empty_file(track.thumbnail_path()) assert os.path.isfile(track.thumbnail_path()) db.session.delete(track) db.session.commit() assert not os.path.isfile(track.thumbnail_path())
def test_can_delete_track_thumbnail(app): track = Track(thumbnail=str(uuid4())) create_empty_file(track.thumbnail_path()) assert os.path.isfile(track.thumbnail_path()) track.delete_thumbnail_file() assert not os.path.isfile(track.thumbnail_path())
def test_track_thumbnail_path_returns_correct_filename(app): app.config["THUMBNAILS_FOLDER"] = "thumbnails" uuid = str(uuid4()) track = Track(thumbnail=uuid) assert track.thumbnail_path() == os.path.join("thumbnails", f"{uuid}.png")