mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 18:52:58 -03:00
Implemented test: test_share_mode_close_after_first_download
This commit is contained in:
parent
70385dd6ac
commit
7ec993d2e0
2 changed files with 26 additions and 4 deletions
|
@ -246,9 +246,13 @@ class Web(object):
|
|||
# Close the server, if necessary
|
||||
if not self.stay_open and not canceled:
|
||||
print(strings._("closing_automatically"))
|
||||
if shutdown_func is None:
|
||||
raise RuntimeError('Not running with the Werkzeug Server')
|
||||
shutdown_func()
|
||||
self.running = False
|
||||
try:
|
||||
if shutdown_func is None:
|
||||
raise RuntimeError('Not running with the Werkzeug Server')
|
||||
shutdown_func()
|
||||
except:
|
||||
pass
|
||||
|
||||
r = Response(generate())
|
||||
r.headers.set('Content-Length', self.zip_filesize)
|
||||
|
|
|
@ -42,6 +42,8 @@ def web_obj(common_obj, recieve_mode, num_files=0):
|
|||
web = Web(common_obj, False, recieve_mode)
|
||||
web.generate_slug()
|
||||
web.stay_open = True
|
||||
web.running = True
|
||||
|
||||
web.app.testing = True
|
||||
|
||||
# Share mode
|
||||
|
@ -67,22 +69,38 @@ class TestWeb:
|
|||
with web.app.test_client() as c:
|
||||
# Load 404 pages
|
||||
res = c.get('/')
|
||||
res.get_data()
|
||||
assert res.status_code == 404
|
||||
|
||||
res = c.get('/invalidslug'.format(web.slug))
|
||||
res.get_data()
|
||||
assert res.status_code == 404
|
||||
|
||||
# Load download page
|
||||
res = c.get('/{}'.format(web.slug))
|
||||
res.get_data()
|
||||
assert res.status_code == 200
|
||||
|
||||
# Download
|
||||
res = c.get('/{}/download'.format(web.slug))
|
||||
res.get_data()
|
||||
assert res.status_code == 200
|
||||
assert res.mimetype == 'application/zip'
|
||||
|
||||
def test_share_mode_close_after_first_download(self, common_obj, temp_file_1024):
|
||||
pass
|
||||
web = web_obj(common_obj, False, 3)
|
||||
web.stay_open = False
|
||||
|
||||
assert web.running == True
|
||||
|
||||
with web.app.test_client() as c:
|
||||
# Download the first time
|
||||
res = c.get('/{}/download'.format(web.slug))
|
||||
res.get_data()
|
||||
assert res.status_code == 200
|
||||
assert res.mimetype == 'application/zip'
|
||||
|
||||
assert web.running == False
|
||||
|
||||
|
||||
class TestZipWriterDefault:
|
||||
|
|
Loading…
Add table
Reference in a new issue