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

Function create_nodes

test/test_shock.py:20–46  ·  view source on GitHub ↗
(FILELIST)

Source from the content-addressed store, hash-verified

18FILELIST = ["AAA.txt", "BBB.txt", "CCC.txt"]
19
20def create_nodes(FILELIST):
21 NODES = []
22 TESTURL = "{SHOCK_URL}/node".format(SHOCK_URL=SHOCK_URL)
23 TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)}
24# to get multipart-form correctly, data has to be specified in this strange way
25# and passed as the files= parameter to requests.put
26 TESTDATA = {"attributes_str": (None, '{"project_id":"TESTPROJECT"}')}
27 for FILE in FILELIST:
28 FILES = {'upload': open(DATADIR + FILE, 'rb')}
29 if DEBUG:
30 print("POST", TESTURL, TESTDATA, TESTHEADERS)
31 response = requests.post(TESTURL, headers=TESTHEADERS, files=FILES, data=TESTDATA)
32 data = json.loads(response.content.decode("utf-8"))
33 assert data["status"] == 200
34 assert data["data"]["attributes"]["project_id"] == "TESTPROJECT"
35 NODES += [data["data"]["id"]]
36 if DEBUG:
37 print("PUT", SHOCK_URL + "/node/" + NODES[-1], TESTDATA)
38 r = requests.put(SHOCK_URL + "/node/" +
39 NODES[-1], files=TESTDATA, headers=TESTHEADERS)
40 if DEBUG:
41 print(r.content.decode("utf-8"))
42 data = json.loads(r.content.decode("utf-8"))
43 if DEBUG:
44 print(data)
45 assert data["data"]["attributes"]["project_id"] == "TESTPROJECT"
46 return(NODES)
47
48
49def confirm_nodes_project(NODES, PROJECT):

Callers 6

test_upload_threefilesFunction · 0.85
test_download_zip_GETFunction · 0.85
test_download_tar_GETFunction · 0.85
test_download_tar_POSTFunction · 0.85
test_download_zip_POSTFunction · 0.85
test_put_attributesstrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected