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
+19 -1
View File
@@ -1,5 +1,23 @@
{
"engines": {},
"engines": {
"Discourse": {
"name": "Discourse",
"site": {
"presenseStrs": [
"<meta name=\"generator\" content=\"Discourse"
],
"absenceStrs": [
"Oops! That page doesn\u2019t exist or is private.",
"wrap not-found-container"
],
"checkType": "message",
"url": "{urlMain}/u/{username}/summary"
},
"presenseStrs": [
"<meta name=\"generator\" content=\"Discourse"
]
}
},
"sites": {
"ValidActive": {
"tags": ["global", "us"],
+37 -7
View File
@@ -6,18 +6,48 @@ from maigret.result import MaigretCheckResult, MaigretCheckStatus
def test_notify_about_errors():
results = {
'site1': {'status': MaigretCheckResult('', '', '', MaigretCheckStatus.UNKNOWN, error=CheckError('Captcha'))},
'site2': {'status': MaigretCheckResult('', '', '', MaigretCheckStatus.UNKNOWN, error=CheckError('Bot protection'))},
'site3': {'status': MaigretCheckResult('', '', '', MaigretCheckStatus.UNKNOWN, error=CheckError('Access denied'))},
'site4': {'status': MaigretCheckResult('', '', '', MaigretCheckStatus.CLAIMED, error=None)},
'site1': {
'status': MaigretCheckResult(
'', '', '', MaigretCheckStatus.UNKNOWN, error=CheckError('Captcha')
)
},
'site2': {
'status': MaigretCheckResult(
'',
'',
'',
MaigretCheckStatus.UNKNOWN,
error=CheckError('Bot protection'),
)
},
'site3': {
'status': MaigretCheckResult(
'',
'',
'',
MaigretCheckStatus.UNKNOWN,
error=CheckError('Access denied'),
)
},
'site4': {
'status': MaigretCheckResult(
'', '', '', MaigretCheckStatus.CLAIMED, error=None
)
},
}
results = notify_about_errors(results, query_notify=None, show_statistics=True)
# Check the output
expected_output = [
('Too many errors of type "Captcha" (25.0%). Try to switch to another ip address or to use service cookies', '!'),
('Too many errors of type "Bot protection" (25.0%). Try to switch to another ip address', '!'),
(
'Too many errors of type "Captcha" (25.0%). Try to switch to another ip address or to use service cookies',
'!',
),
(
'Too many errors of type "Bot protection" (25.0%). Try to switch to another ip address',
'!',
),
('Too many errors of type "Access denied" (25.0%)', '!'),
('Verbose error statistics:', '-'),
('Captcha: 25.0%', '!'),
@@ -25,4 +55,4 @@ def test_notify_about_errors():
('Access denied: 25.0%', '!'),
('You can see detailed site check errors with a flag `--print-errors`', '-'),
]
assert results == expected_output
assert results == expected_output
+1
View File
@@ -15,6 +15,7 @@ from maigret.sites import MaigretSite
from maigret.result import MaigretCheckResult, MaigretCheckStatus
from tests.conftest import RESULTS_EXAMPLE
@pytest.mark.slow
@pytest.mark.asyncio
async def test_self_check_db(test_db):
+31 -15
View File
@@ -7,12 +7,18 @@ def test_gather_strict():
permute = Permute(elements)
result = permute.gather(method="strict")
expected = {
'a_b': 1, 'b_a': 2,
'a-b': 1, 'b-a': 2,
'a.b': 1, 'b.a': 2,
'ab': 1, 'ba': 2,
'_ab': 1, 'ab_': 1,
'_ba': 2, 'ba_': 2
'a_b': 1,
'b_a': 2,
'a-b': 1,
'b-a': 2,
'a.b': 1,
'b.a': 2,
'ab': 1,
'ba': 2,
'_ab': 1,
'ab_': 1,
'_ba': 2,
'ba_': 2,
}
assert result == expected
@@ -22,13 +28,23 @@ def test_gather_all():
permute = Permute(elements)
result = permute.gather(method="all")
expected = {
'a': 1, '_a': 1, 'a_': 1,
'b': 2, '_b': 2, 'b_': 2,
'a_b': 1, 'b_a': 2,
'a-b': 1, 'b-a': 2,
'a.b': 1, 'b.a': 2,
'ab': 1, 'ba': 2,
'_ab': 1, 'ab_': 1,
'_ba': 2, 'ba_': 2
'a': 1,
'_a': 1,
'a_': 1,
'b': 2,
'_b': 2,
'b_': 2,
'a_b': 1,
'b_a': 2,
'a-b': 1,
'b-a': 2,
'a.b': 1,
'b.a': 2,
'ab': 1,
'ba': 2,
'_ab': 1,
'ab_': 1,
'_ba': 2,
'ba_': 2,
}
assert result == expected
assert result == expected