Exemplo n.º 1
0
    def test_validateDocumentWithSchema(self):
        """
        Test that xml sequence listing files are correctly validated 
        against the schema.
        """
        print 'Running %s ...' % getName()
                   
#         valid seql contains the first 2 seqs from f2 - goes via if branch
        f3 = os.path.join(util.TEST_DATA_DIR_PATH, 'test3.xml')
        self.assertTrue(util.validateDocumentWithSchema(f3, util.XML_SCHEMA_PATH))
  
#         ApplicantNamex instead of ApplicantName - goes to except branch
        f4 = os.path.join(util.TEST_DATA_DIR_PATH, 'test4.xml')        
        self.assertFalse(util.validateDocumentWithSchema(f4, util.XML_SCHEMA_PATH))
  
#         SOURCxE instead of SOURCE - goes to else branch 
        f5 = os.path.join(util.TEST_DATA_DIR_PATH, 'test5.xml')        
        self.assertFalse(util.validateDocumentWithSchema(f5, util.XML_SCHEMA_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.validateDocumentWithSchema(f2, util.XML_SCHEMA_PATH))

#         SequenceTotalQuantity element is missing
# TODO: the error msg says that EarliestPriorityApplicationIdentification is expected: /Users/ad/pyton/projects/st26proto/authoringtool/sequencelistings/testData/test8.xml:42:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'SequenceData': This element is not expected. Expected is ( EarliestPriorityApplicationIdentification ).
        f8 = os.path.join(util.TEST_DATA_DIR_PATH, 'test8.xml')
        self.assertFalse(util.validateDocumentWithSchema(f8, util.XML_SCHEMA_PATH))
Exemplo n.º 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()
Exemplo n.º 3
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)

        res = util.validateDocumentWithSchema(f, util.XML_SCHEMA_PATH)
        self.assertIsNone(res['parserError'])
        self.assertIsNone(res['schemaError'])

        self.assertTrue(util.validateDocumentWithDtd(f, util.XML_DTD_PATH))
        sequenceListing.delete()  # TODO: shouldn't be in teardown?