def custom_zw(): zw = web.share_mode.ZipWriter( common.Common(), zip_filename=common.Common.random_string(4, 6), processed_size_callback=lambda _: "custom_callback", ) yield zw zw.close() os.remove(zw.zip_filename)
def default_zw(): zw = web.share_mode.ZipWriter(common.Common()) yield zw zw.close() tmp_dir = os.path.dirname(zw.zip_filename) try: shutil.rmtree(tmp_dir, ignore_errors=True) except: pass
def settings_obj(sys_onionshare_dev_mode, platform_linux): _common = common.Common() _common.version = 'DUMMY_VERSION_1.2.3' return settings.Settings(_common)
def test_filename_windows(self, monkeypatch, platform_windows): monkeypatch.setenv('APPDATA', 'C:') obj = settings.Settings(common.Common()) assert obj.filename.replace('/', '\\') == 'C:\\OnionShare\\onionshare.json'
def test_filename_linux(self, monkeypatch, os_path_expanduser, platform_linux): obj = settings.Settings(common.Common()) assert obj.filename == '~/.config/onionshare/onionshare.json'
def test_filename_darwin(self, monkeypatch, os_path_expanduser, platform_darwin): obj = settings.Settings(common.Common()) assert (obj.filename == '~/Library/Application Support/OnionShare/onionshare.json')
def test_filename_windows(self, monkeypatch, platform_windows): obj = settings.Settings(common.Common()) assert obj.filename == os.path.expanduser( "~\\AppData\\Roaming\\OnionShare-testdata\\onionshare.json")
def test_filename_linux(self, monkeypatch, platform_linux): obj = settings.Settings(common.Common()) assert obj.filename == os.path.expanduser( "~/.config/onionshare-testdata/onionshare.json")
def test_filename_darwin(self, monkeypatch, platform_darwin): obj = settings.Settings(common.Common()) assert obj.filename == os.path.expanduser( "~/Library/Application Support/OnionShare-testdata/onionshare.json" )
def common_obj(): return common.Common()
def default_zw(): zw = web.share_mode.ZipWriter(common.Common()) yield zw zw.close() tmp_dir = os.path.dirname(zw.zip_filename) shutil.rmtree(tmp_dir)
def test_filename_windows(self, monkeypatch, platform_windows): monkeypatch.setenv("APPDATA", "C:") obj = settings.Settings(common.Common()) assert obj.filename.replace("/", "\\") == "C:\\OnionShare\\onionshare.json"