Esempio n. 1
0
    def testUpdateLocalManifestAndDatasetSubmission(self):
        outputStr =  StringIO.StringIO()

        # Invoke dataset submission program, passing faked form submission parameters

        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.formdata, outputStr)
        # Read the dictionary from the manifest
        actualDictionary   = ManifestRDFUtils.getDictionaryFromManifest(TestConfig.ManifestFilePath, TestConfig.ElementUriList)
        Logger.debug("\n Expected Dictionary after form submission= " + repr(ExpectedDictionary))
        Logger.debug("\n Actual Dictionary after form submission =  " + repr(actualDictionary))
        ###print "\n---- actualDictionary ---- \n"+repr(actualDictionary)
        
        # Assert that the ExpectedDictionary == actualDictionary
        self.assertEqual(ExpectedDictionary,actualDictionary, "The submit Utils Tool is unable to fetch metadata information!")
        
        # Invoke dataset submission program with updated information, passing faked updated form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.updatedformdata, outputStr)
        # Read the dictionary from the manifest after processing the form submission with the updated faked  form  data
        actualUpdatedDictionary   = ManifestRDFUtils.getDictionaryFromManifest(TestConfig.ManifestFilePath, TestConfig.ElementUriList)
        Logger.debug("\n Expected Updated Dictionary after form resubmission = " + repr(ExpectedUpdatedDictionary))
        Logger.debug("\n Actual Updated Dictionary after form resubmission =  " + repr(actualUpdatedDictionary))
        
        # Assert that the  ExpectedUpdatedDictionary == actualUpdatedDictionary
        self.assertEqual(ExpectedUpdatedDictionary,actualUpdatedDictionary, "The submit Utils Tool was unable to update form data information in the metadata file!")
        
        return
Esempio n. 2
0
    def testSubmitDatasetHandlerDatasetCreation(self):
        outputStr = StringIO.StringIO()

        # Invoke dataset submission program, passing faked form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(
            TestConfig.formdata, outputStr)

        # Check that the dataset is created
        found = SubmitDatasetUtils.ifDatasetExists(self.session,
                                                   TestConfig.DatasetId)

        self.assertEquals(found, True, "Dataset Creation Failed!")

        # Check that the new dataset can be dereferenced in the databank
        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +
                                "/datasets/" + TestConfig.DatasetId +
                                "-packed",
                                expect_status=200,
                                expect_reason="OK",
                                accept_type="application/json")

        # Check that a HTML Response page is returned
        outputStr.seek(0, os.SEEK_SET)
        firstLine = outputStr.readline()

        # self.assertEqual( firstLine, "Content-type: text/html\n", "Submission Handler could not action the client request!")
        self.assertEqual(
            firstLine.strip(), "Status: 303 Dataset submission successful",
            "Submission Handler could not action the client request!")

        SubmitDatasetUtils.deleteDataset(self.session,
                                         TestConfig.DatasetId + "-packed")
        return
Esempio n. 3
0
    def testSubmitDatasetHandlerDirectorySubmission(self):
        outputStr = StringIO.StringIO()

        # Invoke dataset submission program, passing faked form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(
            TestConfig.formdata, outputStr)

        # Check that the dataset created for unzipped data can be dereferenced in the databank
        datasetId = SubmitDatasetUtils.getFormParam('datId',
                                                    TestConfig.formdata)
        datasetDir = SubmitDatasetUtils.getFormParam('datDir',
                                                     TestConfig.formdata)
        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +
                                "/datasets/" + datasetId + "-packed",
                                expect_status=200,
                                expect_reason="OK",
                                accept_type="application/json")

        # Invoke dataset submission program yet again.
        # This time, bypassing the dataset creation but  continuing submittion of data to the already exiting dataset
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(
            TestConfig.formdata, outputStr)
        # Check that the dataset created for unzipped data can be dereferenced in the databank

        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +
                                "/datasets/" + TestConfig.DatasetId +
                                "-packed",
                                expect_status=200,
                                expect_reason="OK",
                                accept_type="application/json")

        SubmitDatasetUtils.deleteDataset(self.session,
                                         TestConfig.DatasetId + "-packed")
        return
Esempio n. 4
0
    def testSubmitDatasetHandlerHTMLResponse(self):    
        outputStr =  StringIO.StringIO()

        # Invoke dataset submission program, passing faked form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.formdata, outputStr)

        #Logger.debug("Output String from output stream: "+outputStr.getvalue())
        # print "Output String from output stream: "+outputStr.getvalue()
        outputStr.seek(0, os.SEEK_SET)
        firstLine = outputStr.readline()
        Logger.debug("FirstLine = " + firstLine);
        #self.assertEqual( firstLine, "Content-type: text/html\n", "Submission Handler could not action the client request!")
        self.assertEqual( firstLine.strip(), "Status: 303 Dataset submission successful","Submission Handler could not action the client request!")
           
        SubmitDatasetUtils.deleteDataset(self.session, TestConfig.DatasetId +"-packed");
        #SubmitDatasetUtils.deleteDataset(TestConfig.SiloName, datasetId);
        return
 def testSubmitDatasetHandlerDirectorySubmission(self):
     outputStr  =  StringIO.StringIO()
      
     # Invoke dataset submission program, passing faked form submission parameters
     SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.formdata, outputStr)
     
     # Check that the dataset created for unzipped data can be dereferenced in the databank 
     datasetId  =  SubmitDatasetUtils.getFormParam('datId', TestConfig.formdata)
     datasetDir =  SubmitDatasetUtils.getFormParam('datDir', TestConfig.formdata)
     self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +"/datasets/"+datasetId+"-packed",
         expect_status=200, expect_reason="OK", accept_type="application/json")
     
     # Invoke dataset submission program yet again. 
     # This time, bypassing the dataset creation but  continuing submittion of data to the already exiting dataset
     SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.formdata, outputStr)
      # Check that the dataset created for unzipped data can be dereferenced in the databank 
      
     self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +"/datasets/"+TestConfig.DatasetId+"-packed", 
         expect_status=200, expect_reason="OK", accept_type="application/json")
         
     SubmitDatasetUtils.deleteDataset(self.session, TestConfig.DatasetId+"-packed")
     return
Esempio n. 6
0
    def testSubmitDatasetHandlerEmptyDirectorySubmission(self):
        outputStr =  StringIO.StringIO() 
        
        # reset the Dataset Directory to point to an empty directory
        formdata = TestConfig.formdata.copy()
        formdata['datDir'] = cgi.MiniFieldStorage('datDir', TestConfig.DatasetsEmptyDirPath)

        # Invoke dataset submission program, passing faked form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(formdata, outputStr)
        
        # Check that the dataset created for unzipped data can be dereferenced in the databank 
        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +"/datasets/"+TestConfig.DatasetId+"-packed", 
            expect_status=200, expect_reason="OK", accept_type="application/json")
        
        # Invoke dataset submission program yet again. 
        # This time, bypassing the dataset creation but  continuing submittion of data to the already exiting dataset
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(formdata, outputStr)
         # Check that the dataset created for unzipped data can be dereferenced in the databank 
         
        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +"/datasets/"+TestConfig.DatasetId+"-packed", expect_status=200, expect_reason="OK", accept_type="application/json")
        
        SubmitDatasetUtils.deleteDataset(self.session, TestConfig.DatasetId+"-packed")
        return
    def testSubmitDatasetHandlerDatasetDeletion(self):    
        outputStr =  StringIO.StringIO()
         
        # Invoke dataset submission program, passing faked form submission parameters
        SubmitDatasetConfirmationHandler.processDatasetSubmissionForm(TestConfig.formdata, outputStr)
        SubmitDatasetUtils.deleteDataset(self.session, TestConfig.DatasetId)

        # Check that the dataset is deleted
        found = SubmitDatasetUtils.ifDatasetExists(self.session, TestConfig.DatasetId)
            
        self.assertEquals(found, False, "Dataset Deletion Failed!" )     
        
        # Check that the dataset deleted cannot be dereferenced in the databank 
        self.session.doHTTP_GET(resource="/" + TestConfig.SiloName +"/datasets/"+ TestConfig.DatasetId, 
            expect_status=404, expect_reason="Not Found", accept_type="application/json")
        
        # Check that a HTML Response page is returned   
        outputStr.seek(0, os.SEEK_SET)
        firstLine = outputStr.readline()
        # self.assertEqual( firstLine, "Content-type: text/html\n", "Submission Handler could not action the client request!")
        self.assertEqual( firstLine.strip(), "Status: 303 Dataset submission successful","Submission Handler could not action the client request!")
 
        SubmitDatasetUtils.deleteDataset(self.session, TestConfig.DatasetId+"-packed")
        return