feat: add init with host resolution and search verify check

Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
Harold
2026-04-20 13:00:04 +08:00
co-authored by Claude Opus 4.7
parent f190f770c4
commit d76fe86f3a
2 changed files with 36 additions and 1 deletions
+15
View File
@@ -38,3 +38,18 @@ class TestJingyuSpider(unittest.TestCase):
self.spider.host = "http://test.com"
result = self.spider._api_post("someEndpoint")
self.assertEqual(result, payload)
def test_init_fetches_host_from_site_url(self):
init_encrypted = self.spider._aes_encrypt(json.dumps({"type_list": []}))
class FakeInitResponse:
status_code = 200
encoding = "utf-8"
text = "http://example.com"
def json(self):
return {"data": init_encrypted}
self.spider.fetch = lambda url, **kwargs: FakeInitResponse()
self.spider.post = lambda url, **kwargs: FakeInitResponse()
self.spider.init()
self.assertEqual(self.spider.host, "http://example.com")