def test_file_download_callback(): file_download = FileDownload(callback=lambda: StringIO("data"), file="abc") with pytest.raises(ValueError): file_download._clicks += 1 file_download = FileDownload(callback=lambda: StringIO("data"), filename="abc.py") assert file_download.data is None file_download._clicks += 1 assert file_download.data is not None file_download.data = None def cb(): file_download.filename = "cba.py" return StringIO("data") file_download.callback = cb file_download._clicks += 1 assert file_download.data is not None assert file_download.filename == "cba.py" assert file_download.label == "Download cba.py"
def test_file_download_data(): file_download = FileDownload(__file__, embed=True) tfile_data = file_download.data assert tfile_data is not None file_download.file = wfile assert tfile_data != file_download.data file_download.data = None file_download.embed = False file_download.embed = True assert file_download.data is not None file_download.data = None file_download._clicks += 1 assert file_download.data is not None