Added a test for submitter (#1944)

This commit is contained in:
Soxoj
2024-12-08 13:35:27 +01:00
committed by GitHub
parent c66d776f8a
commit 4eada16b94
8 changed files with 105 additions and 30 deletions
+3 -1
View File
@@ -381,7 +381,9 @@ def process_site_result(
extracted_ids_data = extract_ids_data(html_text, logger, site)
if extracted_ids_data:
new_usernames = parse_usernames(extracted_ids_data, logger)
results_info = update_results_info(results_info, extracted_ids_data, new_usernames)
results_info = update_results_info(
results_info, extracted_ids_data, new_usernames
)
result.ids_data = extracted_ids_data
# Save status of request
+1 -1
View File
@@ -174,4 +174,4 @@ def notify_about_errors(
('You can see detailed site check errors with a flag `--print-errors`', '-')
)
return results
return results
+3 -1
View File
@@ -665,7 +665,9 @@ async def main():
check_domains=args.with_domains,
)
errs = errors.notify_about_errors(results, query_notify, show_statistics=args.verbose)
errs = errors.notify_about_errors(
results, query_notify, show_statistics=args.verbose
)
for e in errs:
query_notify.warning(*e)
+10 -4
View File
@@ -1,6 +1,7 @@
import asyncio
import json
import re
import os
from typing import Any, Dict, List, Optional
from aiohttp import ClientSession, TCPConnector
@@ -61,7 +62,10 @@ class Submitter:
proxy = self.args.proxy
cookie_jar = None
if args.cookie_file:
cookie_jar = import_aiohttp_cookies(args.cookie_file)
if not os.path.exists(args.cookie_file):
logger.error(f"Cookie file {args.cookie_file} does not exist!")
else:
cookie_jar = import_aiohttp_cookies(args.cookie_file)
connector = ProxyConnector.from_url(proxy) if proxy else TCPConnector(ssl=False)
connector.verify_ssl = False
@@ -123,7 +127,9 @@ class Submitter:
async def detect_known_engine(
self, url_exists, url_mainpage
) -> [List[MaigretSite], str]:
resp_text = ''
try:
r = await self.session.get(url_mainpage)
content = await r.content.read()
@@ -131,8 +137,8 @@ class Submitter:
resp_text = content.decode(charset, "ignore")
self.logger.debug(resp_text)
except Exception as e:
self.logger.warning(e)
print("Some error while checking main page")
self.logger.warning(e, exc_info=True)
print(f"Some error while checking main page: {e}")
return [], resp_text
for engine in self.db.engines:
@@ -160,7 +166,7 @@ class Submitter:
for u in usernames_to_check:
site_data = {
"urlMain": url_mainpage,
"name": url_mainpage.split("//")[1],
"name": url_mainpage.split("//")[1].split("/")[0],
"engine": engine_name,
"usernameClaimed": u,
"usernameUnclaimed": "noonewouldeverusethis7",