Skip to content

Commit

Permalink
download tests
Browse files Browse the repository at this point in the history
MarvinDo committed Aug 21, 2024
1 parent 2ee6a56 commit 3c5961d
Showing 2 changed files with 18 additions and 20 deletions.
19 changes: 8 additions & 11 deletions src/frontend_celery/webapp/download/download_functions.py
Original file line number Diff line number Diff line change
@@ -121,15 +121,14 @@ def get_vcf(variants_oi, conn, worker=get_variant_vcf_line, check_vcf=True):
return buffer, status, "", ""


import time
def test_large_download():
for i in range(50):
yield str(i).encode()
print(i)
time.sleep(1)



#import time
#def test_large_download():
# for i in range(50):
# yield str(i).encode()
# print(i)
# time.sleep(1)
#
#
def get_vcf_stream(variants_oi, conn, worker=get_variant_vcf_line):
for id in variants_oi:
info_headers, variant_vcf = worker(id, conn)
@@ -140,8 +139,6 @@ def get_vcf_stream(variants_oi, conn, worker=get_variant_vcf_line):
#printable_info_headers = list(final_info_headers.values())
#printable_info_headers.sort()
#functions.write_vcf_header(printable_info_headers, lambda l: yield_something(l.encode()), tail='\n')


def yield_something(val):
yield val

19 changes: 10 additions & 9 deletions src/frontend_celery/webapp/download/download_routes.py
Original file line number Diff line number Diff line change
@@ -77,14 +77,14 @@ def variant_list():


from flask import Response, stream_with_context
@download_blueprint.route('/download/test')
@require_permission(["admin_resources"])
def download_test():
return Response(
stream_with_context(download_functions.test_large_download()),
headers={'Content-Disposition': 'attachment; filename=test.txt'}
)

#@download_blueprint.route('/download/test')
#@require_permission(["admin_resources"])
#def download_test():
# return Response(
# stream_with_context(download_functions.test_large_download()),
# headers={'Content-Disposition': 'attachment; filename=test.txt'}
# )
#
@download_blueprint.route('/download/test_vcf')
@require_permission(["admin_resources"])
def download_test_vcf():
@@ -99,7 +99,8 @@ def download_test_vcf():

return Response(
stream_with_context(download_functions.get_vcf_stream(variant_ids_oi, conn)),
headers={'Content-Disposition': 'attachment; filename=test.txt'}
content_type = "text/event-stream",
headers={'Content-Disposition': 'attachment; filename=test.txt', 'X-Accel-Buffering': 'no'}
)


0 comments on commit 3c5961d

Please sign in to comment.