| 139 | |
| 140 | |
| 141 | def test_upload_and_delete_node(): |
| 142 | TESTURL = "{SHOCK_URL}/node".format(SHOCK_URL=SHOCK_URL) |
| 143 | TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)} |
| 144 | FILES = {'upload': open(DATADIR + 'CCC.txt', 'rb')} |
| 145 | if DEBUG: |
| 146 | print("POST", TESTURL, TESTHEADERS, FILES) |
| 147 | response = requests.post(TESTURL, headers=TESTHEADERS, files=FILES) |
| 148 | data = json.loads(response.content.decode("utf-8")) |
| 149 | NODEID = data["data"]["id"] |
| 150 | # test my node exists |
| 151 | if DEBUG: |
| 152 | print("GET", TESTURL, TESTHEADERS) |
| 153 | TESTURL = SHOCK_URL + "/node/{}".format(NODEID) |
| 154 | TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)} |
| 155 | FILES = {} |
| 156 | response = requests.get(TESTURL, headers=TESTHEADERS) |
| 157 | data = json.loads(response.content.decode("utf-8")) |
| 158 | assert data["status"] == 200 |
| 159 | # delete my node |
| 160 | if DEBUG: |
| 161 | print("DELETE", TESTURL, TESTHEADERS) |
| 162 | TESTURL = SHOCK_URL+"/node/{}".format(NODEID) |
| 163 | TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)} |
| 164 | response = requests.delete(TESTURL, headers=TESTHEADERS) |
| 165 | data = json.loads(response.content.decode("utf-8")) |
| 166 | # test my node is gone |
| 167 | if DEBUG: |
| 168 | print("GET", TESTURL, TESTHEADERS) |
| 169 | TESTURL = SHOCK_URL + "/node/{}".format(NODEID) |
| 170 | TESTHEADERS = {"Authorization": "OAuth {}".format(TOKEN)} |
| 171 | response = requests.get(TESTURL, headers=TESTHEADERS) |
| 172 | data = json.loads(response.content.decode("utf-8")) |
| 173 | assert data["status"] == 404 |
| 174 | |
| 175 | |
| 176 | def test_upload_and_download_node_GET(): |