def test_parse_failure(self):
     """ test parse function failure """
     log.init_log("./log/webpage_parse_test", logging.DEBUG)
     pattern = re.compile(r'.*.(htm|html)')
     html = r'<a href=page1>page 1</a><a href="page2">page 2</a>'
     urls = webpage_parse.parse(html, pattern, logging)
     self.assertTrue(len(urls) == 0)
 def test_parse_success(self):
     """ test parse function success """
     log.init_log("./log/webpage_parse_test", logging.DEBUG)
     pattern = re.compile(r'.*.(htm|html)')
     html = r'<a href=page1.html>page 1</a><a href="page2.html">page 2</a>'
     urls = webpage_parse.parse(html, pattern, logging)
     self.assertTrue(len(urls) > 0)
    def testWebpageParse(self):
        """ test webpage_parse module
        """
        logger = logging.getLogger('testlogger')  
        logger.setLevel(logging.DEBUG)
        ch = logging.StreamHandler()  
        ch.setLevel(logging.DEBUG) 
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') 
        ch.setFormatter(formatter)
        logger.addHandler(ch)  
        pattern = re.compile(r'.*.(htm|html)')
        html = r'<a href=page1.html>page 1</a><a href="page2.html">page 2</a>'

        urls = webpage_parse.parse(html, pattern, logger)
        self.assertTrue(len(urls) > 0)