def testPut(self): # create domain domain = 'valueput.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 10} req = self.endpoint + "/datasets/" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" data = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] payload = {'type': 'H5T_STD_I32LE', 'shape': 10, 'value': data} headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with #create 2d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': (10, 10)} req = self.endpoint + "/datasets/" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset2UUID = rspJson['id'] self.assertTrue(helper.validateId(dset2UUID)) # link new dataset as 'dset2' ok = helper.linkObject(domain, dset2UUID, 'dset2') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset2UUID + "/value" data = [] for i in range(10): row = [] for j in range(10): row.append(i * 10 + j) data.append(row) payload = {'type': 'H5T_STD_I32LE', 'shape': [10, 10], 'value': data} headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset2UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with
def testPut(self): # create domain domain = 'valueput.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 10} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" data = [2,3,5,7,11,13,17,19,23,29] # payload = {'type': 'H5T_STD_I32LE', 'shape': 10, 'value': data } payload = { 'value': data } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with #create 2d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': (10,10)} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset2UUID = rspJson['id'] self.assertTrue(helper.validateId(dset2UUID)) # link new dataset as 'dset2' ok = helper.linkObject(domain, dset2UUID, 'dset2') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset2UUID + "/value" data = [] for i in range(10): row = [] for j in range(10): row.append(i*10 + j) data.append(row) payload = { 'value': data } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset2UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with
def testPutPointSelection(self): # create domain domain = 'valueputpointsel.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 100} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] value = [1,] * len(primes) # write 1's at indexes that are prime # write 1's to all the prime indexes payload = { 'points': primes, 'value': value } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData[37], 1) # prime self.failUnlessEqual(readData[38], 0) # not prime
def testPutCompound(self): domain = 'valueputcompound.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain root_uuid = helper.getRootUUID(domain) headers = {'host': domain} fields = ({'name': 'temp', 'type': 'H5T_STD_I32LE'}, {'name': 'pressure', 'type': 'H5T_IEEE_F32LE'}) datatype = {'class': 'H5T_COMPOUND', 'fields': fields } #create 1d dataset payload = {'type': datatype, 'shape': 2} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset_compound') self.assertTrue(ok) value = ((55, 32.34), (59, 29.34)) payload = {'value': value} req = self.endpoint + "/datasets/" + dset1UUID + "/value" rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # write value
def testPutSelection(self): # create domain domain = 'valueputsel.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 10} req = self.endpoint + "/datasets/" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" data = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] data_part1 = data[0:5] data_part2 = data[5:10] # write part 1 payload = { 'type': 'H5T_STD_I32LE', 'shape': 5, 'start': 0, 'stop': 5, 'value': data_part1 } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # write part 2 payload = { 'type': 'H5T_STD_I32LE', 'shape': 5, 'start': 5, 'stop': 10, 'value': data_part2 } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with
def testPutCompound(self): domain = 'valueputcompound.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain root_uuid = helper.getRootUUID(domain) headers = {'host': domain} fields = ({ 'name': 'temp', 'type': 'H5T_STD_I32LE' }, { 'name': 'pressure', 'type': 'H5T_IEEE_F32LE' }) datatype = {'class': 'H5T_COMPOUND', 'fields': fields} #create 1d dataset payload = {'type': datatype, 'shape': 2} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset_compound') self.assertTrue(ok) value = ((55, 32.34), (59, 29.34)) payload = {'value': value} req = self.endpoint + "/datasets/" + dset1UUID + "/value" rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # write value # selection write payload = {'start': 0, 'stop': 1, 'value': (11.1, 12.2)} req = self.endpoint + "/datasets/" + dset1UUID + "/value" rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # write value
def testPutSelection(self): # create domain domain = 'valueputsel.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 10} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" data = [2,3,5,7,11,13,17,19,23,29] data_part1 = data[0:5] data_part2 = data[5:10] # write part 1 payload = { 'start': 0, 'stop': 5, 'value': data_part1 } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # write part 2 payload = { 'start': 5, 'stop': 10, 'value': data_part2 } headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData, data) # verify we got back what we started with
def testPutPointSelection(self): # create domain domain = 'valueputpointsel.datasettest.' + config.get('domain') req = self.endpoint + "/" headers = {'host': domain} rsp = requests.put(req, headers=headers) self.failUnlessEqual(rsp.status_code, 201) # creates domain #create 1d dataset payload = {'type': 'H5T_STD_I32LE', 'shape': 100} req = self.endpoint + "/datasets" rsp = requests.post(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 201) # create dataset rspJson = json.loads(rsp.text) dset1UUID = rspJson['id'] self.assertTrue(helper.validateId(dset1UUID)) # link new dataset as 'dset1' ok = helper.linkObject(domain, dset1UUID, 'dset1') self.assertTrue(ok) req = self.endpoint + "/datasets/" + dset1UUID + "/value" primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ] value = [ 1, ] * len(primes) # write 1's at indexes that are prime # write 1's to all the prime indexes payload = {'points': primes, 'value': value} headers = {'host': domain} rsp = requests.put(req, data=json.dumps(payload), headers=headers) self.failUnlessEqual(rsp.status_code, 200) # read back the data readData = helper.readDataset(domain, dset1UUID) self.failUnlessEqual(readData[37], 1) # prime self.failUnlessEqual(readData[38], 0) # not prime