Skip to content

Commit e5b763a

Browse files
authored
chore: few more improvements for the academy exercises (#2268)
- removes leftover file spotted by @TC-MO - removes workaround as apify/crawlee-python#1673 has been fixed meanwhile by the Crawlee team - adds tests which verify that each exercise has its test :) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only changes plus deletion of an unused exercise script; minimal production impact, with only a small risk of CI failures if tests are missing or external scraping outputs change. > > **Overview** > Improves the academy webscraping exercise test suites by adding a new "covers all exercise scripts" check in both JS (`*.mjs`) and Python (`*.py`) that fails when any exercise file lacks a corresponding test invocation. > > Removes the leftover `wikipedia_calling_codes.mjs` exercise file, and updates the Python Crawlee Netflix ratings test to assert an exact dataset size (`-eq 5`) instead of the prior workaround. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f68b908. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 9a35701 commit e5b763a

3 files changed

Lines changed: 28 additions & 38 deletions

File tree

sources/academy/webscraping/scraping_basics_javascript/exercises/test.bats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ teardown_file() {
1212
rm -rf node_modules package.json package-lock.json
1313
}
1414

15+
@test "covers all exercise scripts" {
16+
local missing
17+
missing=0
18+
19+
for file in *.mjs; do
20+
if ! grep -q "node $file" test.bats; then
21+
echo "Missing test for $file"
22+
missing=1
23+
fi
24+
done
25+
26+
[[ $missing -eq 0 ]]
27+
}
1528

1629
@test "outputs the HTML with Star Wars products" {
1730
run node lego.mjs

sources/academy/webscraping/scraping_basics_javascript/exercises/wikipedia_calling_codes.mjs

Lines changed: 0 additions & 37 deletions
This file was deleted.

sources/academy/webscraping/scraping_basics_python/exercises/test.bats

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ teardown() {
66
rm -rf products.json storage dataset.json
77
}
88

9+
@test "covers all exercise scripts" {
10+
local missing
11+
missing=0
12+
13+
for file in *.py; do
14+
if ! grep -q "python $file" test.bats; then
15+
echo "Missing test for $file"
16+
missing=1
17+
fi
18+
done
19+
20+
[[ $missing -eq 0 ]]
21+
}
22+
923
@test "outputs the HTML with Star Wars products" {
1024
run uv run -q --with=httpx python lego.py
1125

@@ -141,7 +155,7 @@ teardown() {
141155

142156
(( status == 0 ))
143157
[[ -f dataset.json ]]
144-
[[ $(cat dataset.json | jq '. | length') -gt 5 ]] # should be -eq 5, but there is a bug https://github.com/apify/crawlee-python/issues/1673
158+
[[ $(cat dataset.json | jq '. | length') -eq 5 ]]
145159
[[ $(cat dataset.json | jq -c '.[0] | keys') == '["rating","title","url"]' ]]
146160
[[ $(cat dataset.json | jq '.[].url') == *"https://www.imdb.com/title/"* ]]
147161
}

0 commit comments

Comments
 (0)