MCPcopy Create free account
hub / github.com/MG-RAST/Shock / test_download_zip_POST

Function test_download_zip_POST

test/test_shock.py:403–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

401
402
403def test_download_zip_POST():
404 # Per test invokation on https://github.com/MG-RAST/Shock/wiki/API
405 # use download_url with a POST and list of node ids
406 # curl -X POST -F "download_url=1" -F "archive_format=zip" -F "ids=<node_id_1>,<node_id_2>,<...>" http://<host>[:<port>]/node
407 NODES = create_nodes(FILELIST)
408 # confirm nodes exist
409 confirm_nodes_project(NODES, "TESTPROJECT")
410 # query for TESTDATA
411 TESTURL = "{SHOCK_URL}/node".format(SHOCK_URL=SHOCK_URL)
412 TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)}
413 # Remember, multipart-forms that are not files have format {key: (None, value)}
414 TESTDATA = {"ids": (None, ",".join(NODES)),
415 "download_url": (None, 1),
416 "archive_format": (None, "zip")}
417 # issue query for TESTPROJECT FILES downloaded as TAR
418 if DEBUG:
419 print("POST", TESTURL, TESTDATA)
420 response = requests.post(TESTURL, headers=TESTHEADERS, files=TESTDATA)
421 data = json.loads(response.content.decode("utf-8"))
422 # extract preauth uri from response
423 if DEBUG:
424 print(response)
425 PREAUTH = data["data"]["url"]
426 print("Debugging receiving : " + PREAUTH )
427 response = requests.get(PREAUTH, headers=TESTHEADERS)
428 print("Debugging status code: " + str(response.status_code))
429 # write it to file and test ZIP
430 with open("TESTP.zip", "wb") as f:
431 f.write(response.content)
432 out = check_output("unzip -l TESTP.zip", shell=True)
433 assert b'CCC.txt' in out
434 assert b' 4 ' in out # This fails if there are no 4-byte-files
435 # cleanup
436 delete_nodes(NODES)
437
438def test_put_attributesstr():
439 NODE = create_nodes(["AAA.txt"])[0]

Callers

nothing calls this directly

Calls 4

create_nodesFunction · 0.85
confirm_nodes_projectFunction · 0.85
delete_nodesFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected