def test_file_download_filename(tmpdir): file_download = FileDownload() filepath = tmpdir.join("foo.txt") filepath.write("content") file_download.file = str(filepath) assert file_download.filename == "foo.txt" file_download._clicks += 1 file_download.file = __file__ assert file_download.filename == "test_misc.py" file_download.file = StringIO("data") assert file_download.filename == "test_misc.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