def test3UpdateSiloInfo(self):
     """Update silo metadata"""
     fields = \
         [ ("silo", self.testsilo),
           ("title", "Sandbox silo"),
           ("description", "Sandbox silo for testing"),
           ("notes", "Created by test"),
           ("owners", "%s,%s"%(RDFDatabankConfig.endpointadminuser,RDFDatabankConfig.endpointuser)),
           ("disk_allocation", "200000")
         ]
     files =[]
     (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
     (resp,respdata) = self.doHTTP_POST(reqdata, reqtype,
         endpointpath="/%s/"%self.testsilo, resource="admin/",
         expect_status=204, expect_reason="Updated", expect_type="text/plain")
     # Access silo information in admin, check response
     (resp, data) = self.doHTTP_GET(
         endpointpath="/%s/"%self.testsilo, 
         resource="admin/",
         expect_status=200, expect_reason="OK", expect_type="application/json")
     # check silo name and base_uri
     self.assertEqual(data['title'], "Sandbox silo", "Silo title is %s not 'Sandbox silo'" %data['title'])
     self.assertEqual(data['description'], "Sandbox silo for testing", "Silo title is '%s' not 'Sandbox silo for testing'" %data['description'])
     self.assertEqual(data['notes'], "Created by test", "Silo notes is '%s' not 'Created by test'" %data['notes'])
     self.assertEqual(data['owners'], "%s,%s"%(RDFDatabankConfig.endpointadminuser,RDFDatabankConfig.endpointuser), "Silo owner is '%s' not '%s,%s'" %(data['owners'], RDFDatabankConfig.endpointadminuser,RDFDatabankConfig.endpointuser))
     self.assertEqual(data['disk_allocation'], "200000", "Silo title is '%s' not '200000'" %data['disk_allocation'])
     return
Example #2
0
 def createSubmissionDataset(self, dataset_id='TestSubmission'):
     # Create a new dataset, check response
     fields = \
         [ ("id", dataset_id)
         ]
     files =[]
     (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
     (resp,respdata) = self.doHTTP_POST(
         reqdata, reqtype, 
         resource="datasets/", 
         expect_status=201, expect_reason="Created")
     LHobtained = resp.getheader('Content-Location', None)
     LHexpected = "%sdatasets/%s"%(self._endpointpath, dataset_id)
     self.assertEquals(LHobtained, LHexpected, 'Content-Location not correct')
     return
Example #3
0
 def updateSubmissionZipfile(self, dataset_id='TestSubmission', file_to_upload="testdir.zip", filename=None):
     # Submit ZIP file, check response
     fields = []
     if filename:
         fields = \
             [ ("filename", filename)
             ]
     zipdata = open("testdata/%s"%file_to_upload).read()
     files = \
         [ ("file", file_to_upload, zipdata, "application/zip") 
         ]
     (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
     (resp,respdata)= self.doHTTP_POST(
         reqdata, reqtype, 
         resource="datasets/%s/"%dataset_id, 
         expect_status=204, expect_reason="No Content")
     return zipdata
Example #4
0
 def test01CreateSilo(self):
     """List all silos your account has access to - GET /admin. If the silo 'sandbox' does not exist, create it"""
     self.setRequestUserPass(
         endpointuser=RDFDatabankConfig.endpointadminuser,
         endpointpass=RDFDatabankConfig.endpointadminpass)
     # Access list silos, check response
     (resp, data) = self.doHTTP_GET(
         endpointpath="/",
         resource="admin/",
         expect_status=200, expect_reason="OK", expect_type="application/JSON")
     silo_name = RDFDatabankConfig.endpointpathl.strip('/')
     silolist = data
     if not silo_name in silolist:
         #Create new silo
         owner_list = [RDFDatabankConfig.endpointadminuser]
         if not RDFDatabankConfig.endpointuser in owner_list:
             owner_list.append(RDFDatabankConfig.endpointuser)
         owner_list = ",".join(owner_list)
         fields = \
             [ ("silo", silo_name),
               ("title", "Sandbox silo"),
               ("description", "Sandbox silo for testing"),
               ("notes", "Created by test"),
               ("owners", owner_list),
               ("disk_allocation", "100000")
             ]
         files =[]
         (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
         (resp,respdata) = self.doHTTP_POST(
             reqdata, reqtype, resource="admin/", endpointpath="/",
             expect_status=201, expect_reason="Created")
         LHobtained = resp.getheader('Content-Location', None)
         LHexpected = "/%s"%silo_name
         self.assertEquals(LHobtained, LHexpected, 'Content-Location not correct')
         # Access list silos, check response
         (resp, data) = self.doHTTP_GET(
             endpointpath="/",
             resource="admin/",
             expect_status=200, expect_reason="OK", expect_type="application/json")
         newsilolist = data
         self.failUnless(len(newsilolist)>0, "No silos returned")
         self.assertEquals(len(newsilolist), len(silolist)+1, "One additional silo should have been returned")
         for s in silolist: self.failUnless(s in newsilolist, "Silo "+s+" in original list, not in new list")
         self.failUnless(silo_name in newsilolist, "Silo '%s' not in new list"%silo_name)
     return
 def test1CreateSilo(self):
     """List all silos your account has access to - GET /silo"""
     #Write a test to list all the silos. Test to see if it returns 200 OK and the list of silos is not empty
     # Access list silos, check response
     (resp, data) = self.doHTTP_GET(
         endpointpath="/",
         resource="admin/", 
         expect_status=200, expect_reason="OK", expect_type="application/JSON")
     #Create new silo
     silolist = data
     fields = \
         [ ("silo", self.testsilo),
           ("title", "Sandbox silo"),
           ("description", "Sandbox silo for testing"),
           ("notes", "Created by test"),
           ("owners", RDFDatabankConfig.endpointadminuser),
           ("disk_allocation", "100000")
         ]
     files =[]
     (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
     (resp,respdata) = self.doHTTP_POST(
         reqdata, reqtype, resource="admin/", endpointpath="/", 
         expect_status=201, expect_reason="Created")
     LHobtained = resp.getheader('Content-Location', None)
     LHexpected = "/%s"%self.testsilo
     self.assertEquals(LHobtained, LHexpected, 'Content-Location not correct')
     # Access list silos, check response
     (resp, data) = self.doHTTP_GET(
         endpointpath="/",
         resource="admin/", 
         expect_status=200, expect_reason="OK", expect_type="application/json")
     #newsilolist = []
     #for k in data:
     #    newsilolist.append(k)
     newsilolist = data
     self.failUnless(len(newsilolist)>0, "No silos returned")
     self.assertEquals(len(newsilolist), len(silolist)+1, "One additional silo should have been returned")
     for s in silolist: self.failUnless(s in newsilolist, "Silo "+s+" in original list, not in new list")
     self.failUnless(self.testsilo in newsilolist, "Silo "+self.testsilo+" not in new list")
     return   
Example #6
0
 def uploadSubmissionZipfile(self, dataset_id='TestSubmission', file_to_upload="testdir.zip", filename=None):
     # Submit ZIP file, check response
     fields = []
     if filename:
         fields = \
             [ ("filename", filename)
             ]
     else:
         filename = file_to_upload
     zipdata = open("testdata/%s"%file_to_upload).read()
     files = \
         [ ("file", file_to_upload, zipdata, "application/zip") 
         ]
     (reqtype, reqdata) = SparqlQueryTestCase.encode_multipart_formdata(fields, files)
     (resp,respdata) = self.doHTTP_POST(
         reqdata, reqtype, 
         resource="datasets/%s/"%dataset_id, 
         expect_status=201, expect_reason="Created")
     LHobtained = resp.getheader('Content-Location', None)
     LHexpected = "%sdatasets/%s/%s"%(self._endpointpath, dataset_id, filename)
     self.assertEquals(LHobtained, LHexpected, 'Content-Location not correct')
     return zipdata