mirror of
https://github.com/soxoj/maigret.git
synced 2026-05-06 14:08:59 +00:00
Added Max.ru check; --no-progressbar flag fixed (#2386)
This commit is contained in:
+2
-1
@@ -1019,6 +1019,7 @@ async def self_check(
|
|||||||
i2p_proxy=None,
|
i2p_proxy=None,
|
||||||
auto_disable=False,
|
auto_disable=False,
|
||||||
diagnose=False,
|
diagnose=False,
|
||||||
|
no_progressbar=False,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""
|
"""
|
||||||
Run self-check on sites.
|
Run self-check on sites.
|
||||||
@@ -1053,7 +1054,7 @@ async def self_check(
|
|||||||
tasks.append((site.name, future))
|
tasks.append((site.name, future))
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
with alive_bar(len(tasks), title='Self-checking', force_tty=True) as progress:
|
with alive_bar(len(tasks), title='Self-checking', force_tty=True, disable=no_progressbar) as progress:
|
||||||
for site_name, f in tasks:
|
for site_name, f in tasks:
|
||||||
result = await f
|
result = await f
|
||||||
result['site_name'] = site_name
|
result['site_name'] = site_name
|
||||||
|
|||||||
@@ -600,6 +600,7 @@ async def main():
|
|||||||
i2p_proxy=args.i2p_proxy,
|
i2p_proxy=args.i2p_proxy,
|
||||||
auto_disable=args.auto_disable,
|
auto_disable=args.auto_disable,
|
||||||
diagnose=args.diagnose,
|
diagnose=args.diagnose,
|
||||||
|
no_progressbar=args.no_progressbar,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Handle both old (bool) and new (dict) return types
|
# Handle both old (bool) and new (dict) return types
|
||||||
|
|||||||
@@ -15165,6 +15165,23 @@
|
|||||||
"usernameClaimed": "adam",
|
"usernameClaimed": "adam",
|
||||||
"usernameUnclaimed": "noonewouldeverusethis7"
|
"usernameUnclaimed": "noonewouldeverusethis7"
|
||||||
},
|
},
|
||||||
|
"Max": {
|
||||||
|
"tags": [
|
||||||
|
"messaging",
|
||||||
|
"ru"
|
||||||
|
],
|
||||||
|
"checkType": "message",
|
||||||
|
"presenseStrs": [
|
||||||
|
"channel:{title:\""
|
||||||
|
],
|
||||||
|
"absenceStrs": [
|
||||||
|
"\u041d\u0435 \u043d\u0430\u0448\u043b\u0438 \u0447\u0430\u0442 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435"
|
||||||
|
],
|
||||||
|
"urlMain": "https://max.ru",
|
||||||
|
"url": "https://max.ru/{username}",
|
||||||
|
"usernameClaimed": "ivolk",
|
||||||
|
"usernameUnclaimed": "noonewouldeverusethis7"
|
||||||
|
},
|
||||||
"Maxpark": {
|
"Maxpark": {
|
||||||
"disabled": true,
|
"disabled": true,
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import copy
|
import copy
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
@@ -37,6 +38,51 @@ async def test_self_check_db(test_db):
|
|||||||
assert test_db.sites_dict['InvalidInactive'].disabled is True
|
assert test_db.sites_dict['InvalidInactive'].disabled is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.slow
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_self_check_no_progressbar(test_db):
|
||||||
|
"""Verify that no_progressbar=True disables the alive_bar in self_check."""
|
||||||
|
logger = Mock()
|
||||||
|
|
||||||
|
with patch('maigret.checking.alive_bar') as mock_alive_bar:
|
||||||
|
mock_bar = Mock()
|
||||||
|
mock_alive_bar.return_value.__enter__ = Mock(return_value=mock_bar)
|
||||||
|
mock_alive_bar.return_value.__exit__ = Mock(return_value=False)
|
||||||
|
|
||||||
|
await self_check(
|
||||||
|
test_db, test_db.sites_dict, logger, silent=True,
|
||||||
|
no_progressbar=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# First call is the self-check progress bar; subsequent calls are
|
||||||
|
# from inner search() invocations.
|
||||||
|
self_check_call = mock_alive_bar.call_args_list[0]
|
||||||
|
_, kwargs = self_check_call
|
||||||
|
assert kwargs.get('title') == 'Self-checking'
|
||||||
|
assert kwargs.get('disable') is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.slow
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_self_check_progressbar_enabled_by_default(test_db):
|
||||||
|
"""Verify that alive_bar is enabled by default (no_progressbar=False)."""
|
||||||
|
logger = Mock()
|
||||||
|
|
||||||
|
with patch('maigret.checking.alive_bar') as mock_alive_bar:
|
||||||
|
mock_bar = Mock()
|
||||||
|
mock_alive_bar.return_value.__enter__ = Mock(return_value=mock_bar)
|
||||||
|
mock_alive_bar.return_value.__exit__ = Mock(return_value=False)
|
||||||
|
|
||||||
|
await self_check(
|
||||||
|
test_db, test_db.sites_dict, logger, silent=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self_check_call = mock_alive_bar.call_args_list[0]
|
||||||
|
_, kwargs = self_check_call
|
||||||
|
assert kwargs.get('title') == 'Self-checking'
|
||||||
|
assert kwargs.get('disable') is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
@pytest.mark.skip(reason="broken, fixme")
|
@pytest.mark.skip(reason="broken, fixme")
|
||||||
def test_maigret_results(test_db):
|
def test_maigret_results(test_db):
|
||||||
|
|||||||
Reference in New Issue
Block a user