mirror of
https://github.com/simon987/opendirectories-bot.git
synced 2025-12-16 08:39:02 +00:00
Fixed bugs, enhanced parser
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from parser import ApacheParser, NginxParser
|
||||
from crawler import Crawler
|
||||
|
||||
|
||||
class CrawlerTest(TestCase):
|
||||
|
||||
def test_guess_parser1(self):
|
||||
|
||||
with open("test_apache1.html", "r") as f:
|
||||
text = f.read()
|
||||
|
||||
c = Crawler("http://some.website/", False)
|
||||
|
||||
self.assertEqual(c.guess_parser(text, {}), ApacheParser)
|
||||
|
||||
def test_guess_parser2(self):
|
||||
with open("test_nginx1.html", "r") as f:
|
||||
text = f.read()
|
||||
|
||||
c = Crawler("http://some.website", False)
|
||||
|
||||
self.assertEqual(c.guess_parser(text, {}), NginxParser)
|
||||
|
||||
def test_guess_parser3(self):
|
||||
with open("test_invalid.html", "r") as f:
|
||||
text = f.read()
|
||||
|
||||
c = Crawler("http://some.website", False)
|
||||
|
||||
self.assertEqual(c.guess_parser(text, {}), None)
|
||||
Reference in New Issue
Block a user