Stabilize downloader engine and browser routing - #66
Conversation
LeyckerS
left a comment
There was a problem hiding this comment.
Thanks for this @Abel-et — and you did claim #57 first, so it's yours. tests/test_snapshot.py is real work on the part that matters: four of those five tests exercise the contract properly, and the log-cursor one in particular gets the dropped/begin arithmetic right, which is the easiest part of snapshot() to get wrong.
I can't merge it as it stands, though, because most of the diff is not what the description says it is. I checked each bullet against the diff rather than taking the summary's word for it:
- "Added browser routing regression tests" —
tests/test_engine.pyis an empty file (+0 −0, blobe69de29). There are no browser-routing tests anywhere in this PR. Thetests/conftest.pychange is whitespace only: reflowing a dict literal and amonkeypatch.setattrcall. - "Stabilized engine counters and log cursor behavior" — the
moon_engine.pydiff touches no counter and no cursor code.snapshot()(moon_engine.py:556-614) andstart()'s reset block (moon_engine.py:462-472) are both untouched. - "Verified CLI and engine share extraction/download flow" — nothing in the diff does this.
Please make the description match the diff. I quote PR descriptions in the changelog, and I'd be crediting you with work that isn't here.
Now the changes to moon_engine.py, which are the blocking part:
1. _LOG_MAX_LINES stops being a class attribute. It moves from 4 spaces to 8, landing after the return in _get() — so it becomes an unreachable local assignment instead of Engine._LOG_MAX_LINES. To be fair to you: nothing in the repo reads it today, so this doesn't break anything at runtime. But that makes it worse, not better — it turns a named constant into dead code buried inside an unrelated method. If it should go, delete it in its own PR and I'll take that.
2. The _cfg dict is reindented to column 0 and loses its comments. It still parses (it's inside braces, so the indentation is legal), but moon_engine.py:99-100 explained why the defaults are 8 lanes and a 30s captcha wait — that they were asked for by the operator, not by the library. That's the kind of comment I can't reconstruct later. The key alignment goes too.
3. log() loses its docstring and changes its default tag from "" to "info". Every internal caller passes a tag explicitly, so no test in this PR covers the change. A public-surface behaviour change with no stated reason and no test is the opposite of what this PR is for — it's meant to pin the front-end contract, not move it.
4. _log() is dead code. Nothing in the repo or in this PR calls it.
5. .github/workflows/lint.yml — pytest → python -m pytest isn't needed: tests/conftest.py:10-11 already does sys.path.insert(0, ROOT), which is why that job is green on main today.
There is a real gap next to it, if you want it: the syntax-check job byte-compiles an explicit file list that stops at tests/test_no_chrome.py, so your new test file never gets compiled. Adding tests/test_snapshot.py to that compileall list would make the workflow change earn its place.
Smaller things in test_snapshot.py:
import timeis unused.- No blank lines between
test_snapshot_log_cursor_returns_only_new_logsandtest_start_resets_previous_run_counters, and no trailing newline (same inconftest.py). Nothing fails on this — there's no ruff in CI yet, that's #26 — but it's worth fixing. test_start_resets_previous_run_countersreally does runstart(), which calls_moon_extract.configure()and_PROXY_POOL.load()for real (moon_engine.py:476-483). Your_guarded_runstub does work — the thread target resolves the attribute at call time — so no worker thread runs, but the test still mutates global extractor state and readsproxies.txtoff disk. Worth stubbing those two as well.
What I'd merge: keep tests/test_snapshot.py, revert moon_engine.py to main, delete the empty tests/test_engine.py, revert the conftest.py formatting churn, and either drop the lint.yml change or turn it into the compileall fix above. That's a clean PR that closes #57, and I'll take it as soon as it's pushed.
|
@Abel-et — not chasing you, the five-day window is nowhere near up. This is information you cannot see from your branch and that changes the cheapest way to finish.
So "revert The cheap path, and what I would do: branch fresh from current I checked your test file against current Two things worth folding in while you are there, both from my original review and both small:
Your snapshot tests are the reason I want this merged — #57 has been open a while and nobody else has touched it. Open the new PR whenever suits you and close this one, or push over this branch if you prefer; either is fine. |
|
@Abel-et — the five days I mentioned are up today. I am not closing this, and I want to be clear why: you did the work. The offer from 1 August stands and has only got easier. Branch fresh from I re-checked your test file against current Three ways this can go, all fine:
The rule exists so an issue nobody is working on does not sit frozen. You worked on it. That is a different situation and I am treating it as one. |
Changes:

Tests:
Result:
16 passed, 1 warning