Skip to content

Commit ee39e28

Browse files
authored
Show total and number of attachments checked (#1662)
1 parent 7ca5ce3 commit ee39e28

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

checks/remotesettings/attachments_availability.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ async def run(server: str, slice_percent: tuple[int, int] = (0, 100)) -> CheckRe
5353

5454
lower_idx = math.floor(slice_percent[0] / 100.0 * len(urls))
5555
upper_idx = math.ceil(slice_percent[1] / 100.0 * len(urls))
56+
sliced = urls[lower_idx:upper_idx]
5657

57-
futures = [test_url(url) for url in urls[lower_idx:upper_idx]]
58+
futures = [test_url(url) for url in sliced]
5859
results = await run_parallel(*futures)
59-
missing = [url for url, success in zip(urls, results) if not success]
60+
missing = [url for url, success in zip(sliced, results) if not success]
6061

61-
return len(missing) == 0, {"missing": missing, "checked": len(urls)}
62+
return len(missing) == 0, {
63+
"missing": missing,
64+
"checked": len(sliced),
65+
"total": len(urls),
66+
}

checks/remotesettings/attachments_integrity.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ async def run(server: str, slice_percent: tuple[int, int] = (0, 100)) -> CheckRe
7979

8080
lower_idx = math.floor(slice_percent[0] / 100.0 * len(attachments))
8181
upper_idx = math.ceil(slice_percent[1] / 100.0 * len(attachments))
82+
sliced = attachments[lower_idx:upper_idx]
8283

83-
futures = [
84-
test_attachment(attachment) for attachment in attachments[lower_idx:upper_idx]
85-
]
84+
futures = [test_attachment(attachment) for attachment in sliced]
8685
results = await run_parallel(*futures)
8786
bad = [result for result, success in results if not success]
88-
return len(bad) == 0, {"bad": bad, "checked": len(attachments)}
87+
return len(bad) == 0, {
88+
"bad": bad,
89+
"checked": len(sliced),
90+
"total": len(attachments),
91+
}

tests/checks/remotesettings/test_attachments_availability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def test_positive(mock_aioresponses):
4141
status, data = await run(server_url)
4242

4343
# assert status is True
44-
assert data == {"missing": [], "checked": 2}
44+
assert data == {"missing": [], "checked": 2, "total": 2}
4545

4646

4747
async def test_negative(mock_aioresponses, no_sleep):
@@ -79,7 +79,7 @@ async def test_negative(mock_aioresponses, no_sleep):
7979
status, data = await run(server_url)
8080

8181
assert status is False
82-
assert data == {"missing": ["http://cdn/missing.jpg"], "checked": 2}
82+
assert data == {"missing": ["http://cdn/missing.jpg"], "checked": 2, "total": 2}
8383

8484

8585
@pytest.mark.parametrize(

tests/checks/remotesettings/test_attachments_integrity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def test_positive(mock_aioresponses):
5555
status, data = await run(server_url)
5656

5757
# assert status is True
58-
assert data == {"bad": [], "checked": 2}
58+
assert data == {"bad": [], "checked": 2, "total": 2}
5959

6060

6161
async def test_negative(mock_aioresponses):
@@ -130,6 +130,7 @@ async def test_negative(mock_aioresponses):
130130
},
131131
],
132132
"checked": 4,
133+
"total": 4,
133134
}
134135

135136

0 commit comments

Comments
 (0)