Пример #1
0
    def test_validateDocumentWithDtd(self):
        """
        Test that xml sequence listing files are correctly validated 
        against the dtd.
        """
        print 'Running %s ...' % getName()
                   
#         valid seql contains the first 2 seqs from f2
        f3 = os.path.join(util.TEST_DATA_DIR_PATH, 'test3.xml')
        self.assertTrue(util.validateDocumentWithDtd(f3, util.XML_DTD_PATH))
        
#         SOURCxE instead of SOURCE. It passes the validation bc there is no
#         restriction defined in dtd on the value of an element
        f5 = os.path.join(util.TEST_DATA_DIR_PATH, 'test5.xml')        
        self.assertTrue(util.validateDocumentWithDtd(f5, util.XML_DTD_PATH))
        
#         supplementary test with seql with more sequences
#         valid seql 20 sequences
        f2 = os.path.join(util.TEST_DATA_DIR_PATH, 'test2.xml')
        self.assertTrue(util.validateDocumentWithDtd(f2, util.XML_DTD_PATH))
        
#         ApplicantNamey instead of ApplicantName - except branch
        f6 = os.path.join(util.TEST_DATA_DIR_PATH, 'test6.xml')
        self.assertFalse(util.validateDocumentWithDtd(f6, util.XML_DTD_PATH))

#         ApplicantsName open and closing tags instead of ApplicantName - else branch
        f7 = os.path.join(util.TEST_DATA_DIR_PATH, 'test7.xml')
        self.assertFalse(util.validateDocumentWithDtd(f7, util.XML_DTD_PATH))
        
#         SequenceTotalQuantity element is missing
        f8 = os.path.join(util.TEST_DATA_DIR_PATH, 'test8.xml')
        self.assertFalse(util.validateDocumentWithDtd(f8, util.XML_DTD_PATH))
Пример #2
0
    def test_helper_generateXml(self):
        print 'Running %s ...' % getName()
        
        sequenceListing = self.sequenceListingFixture.create_sequencelisting_instance()
        self.sequenceListingFixture.create_sequence_instance(sequenceListing)
#         TODO: generate some fancy sequences to check xml validation?
        util.helper_generateXml(sequenceListing)
        
        f =  os.path.join(util.OUTPUT_DIR, '%s.xml' % sequenceListing.fileName)

        self.assertTrue(util.validateDocumentWithSchema(f, util.XML_SCHEMA_PATH))
        self.assertTrue(util.validateDocumentWithDtd(f, util.XML_DTD_PATH))
        sequenceListing.delete()