2018-10-03 11:05:42 +02:00
|
|
|
import unittest
|
2018-10-03 21:01:52 +02:00
|
|
|
from pprint import pprint
|
2018-10-03 11:05:42 +02:00
|
|
|
|
|
|
|
from spider.spider import check_and_rate_site
|
|
|
|
|
2018-10-03 21:01:52 +02:00
|
|
|
class TestSpider(unittest.TestCase):
|
2018-10-03 11:05:42 +02:00
|
|
|
|
2018-10-03 21:01:52 +02:00
|
|
|
"""
|
|
|
|
Simply calls the spider.check_and_rate_site function
|
|
|
|
with httpbin.org URLs. We don't assert a lot here,
|
|
|
|
but at least make sure that most of our code is executed
|
|
|
|
in tests.
|
|
|
|
"""
|
2018-10-03 11:05:42 +02:00
|
|
|
|
2018-10-03 21:01:52 +02:00
|
|
|
def test_html(self):
|
|
|
|
"""Loads a simple HTML web page"""
|
2018-10-03 11:05:42 +02:00
|
|
|
|
|
|
|
entry = {
|
|
|
|
"url": "https://httpbin.org/html",
|
|
|
|
"type": "type",
|
|
|
|
"state": "state",
|
|
|
|
"level": "level",
|
|
|
|
"district": "district",
|
|
|
|
"city": "city",
|
|
|
|
}
|
|
|
|
|
|
|
|
url = "https://httpbin.org/html"
|
|
|
|
result = check_and_rate_site(entry)
|
|
|
|
|
|
|
|
self.assertEqual(result["input_url"], url)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|