Move the cleanup() function from Onionshare class to Web class, so that the list of files to be cleaned up is always available (needed for website temp files)

This commit is contained in:
Miguel Jacq 2021-05-04 16:21:42 +10:00
parent e48b300ff9
commit ff5e73a2ae
10 changed files with 40 additions and 38 deletions

View file

@ -51,6 +51,7 @@ def web_obj(temp_dir, common_obj, mode, num_files=0):
web.generate_password()
web.running = True
web.cleanup_filenames == []
web.app.testing = True
# Share mode
@ -345,6 +346,16 @@ class TestWeb:
res.get_data()
assert res.status_code == 200
def test_cleanup(self, common_obj, temp_dir_1024, temp_file_1024):
web = web_obj(temp_dir_1024, common_obj, "share", 3)
web.cleanup_filenames = [temp_dir_1024, temp_file_1024]
web.cleanup()
assert os.path.exists(temp_file_1024) is False
assert os.path.exists(temp_dir_1024) is False
assert web.cleanup_filenames == []
def _make_auth_headers(self, password):
auth = base64.b64encode(b"onionshare:" + password.encode()).decode()
h = Headers()