예제 #1
0
 def test_registry_delete_by_mime(self):
     handler = self.make_handler('script', 'test/mime')
     self.assertTrue('test/mime' in HandlerRegistry.scripts)
     HandlerRegistry.delete_handler('test/mime')
     self.assertTrue('test/mime' not in HandlerRegistry.scripts)
     
     handler = self.make_handler('style', 'test/mime')
     self.assertTrue('test/mime' in HandlerRegistry.styles)
     HandlerRegistry.delete_handler('test/mime')
     self.assertTrue('test/mime' not in HandlerRegistry.styles)
예제 #2
0
    def test_registry_delete_by_mime(self):
        handler = self.make_handler('script', 'test/mime')
        self.assertTrue('test/mime' in HandlerRegistry.scripts)
        HandlerRegistry.delete_handler('test/mime')
        self.assertTrue('test/mime' not in HandlerRegistry.scripts)

        handler = self.make_handler('style', 'test/mime')
        self.assertTrue('test/mime' in HandlerRegistry.styles)
        HandlerRegistry.delete_handler('test/mime')
        self.assertTrue('test/mime' not in HandlerRegistry.styles)
예제 #3
0
 def script_files(self):
     """
     Gets script files (hrefs) from two types of tags and return a list
     of tuples of (src, type)
     """
     script_nodes = self.tree.xpath('script[@src]')
     link_paths = ['link[@type="%s"]' % mime for mime in HandlerRegistry.script_mimes()]
     link_nodes = self.tree.xpath('|'.join(link_paths))
     return [(node.attrib['src'], node.attrib['type']) for node in script_nodes] + \
            [(node.attrib['href'], node.attrib['type']) for node in link_nodes]