Closed aryanA101a closed 7 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
538f8af
) to head (f114d38
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think a versioned zimscraperlib UA is fine as long as it's easy to change in scrapers. Contact should be dev@openzim.org
@benoit74 Sure, I'll keep it in mind.
@benoit74 There is tight coupling in our context, which makes it impossible to test without significant refactoring.
@benoit74 @rgaudin To make it such that UA can be changed.
def handle_user_provided_file(
source: Optional[Union[pathlib.Path, str]] = None,
dest: Optional[pathlib.Path] = None,
in_dir: Optional[pathlib.Path] = None,
nocopy: bool = False, # noqa: FBT001, FBT002
user_agent: Optional[str]=f"{PROJECT_NAME.replace(' ','/')} ({CONTACT})"
)
There is tight coupling in our context, which makes it impossible to test without significant refactoring.
In one (or more) test of handle_user_provided_file
, you can use pytest monkeypatch
on stream_file
and assert that proper header (User-Agent) is passed. No refactoring needed.
To make it such that UA can be changed, it requires a breaking change.
I don't get where you see a breaking change, could you develop your concern?
In one (or more) test of
handle_user_provided_file
, you can use pytestmonkeypatch
onstream_file
and assert that proper header (User-Agent) is passed. No refactoring needed.
Okay, I was unaware of monkey patching.
I don't get where you see a breaking change, could you develop your concern?
Nahh, it's alright. There was a bitflip in my brain.
Side note, @aryanA101a you need to update your first comment to write Fix #xxx
(instead of #xxx
) so that corresponding issue is automatically closed once the PR is merged (https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
@rgaudin final review is welcomed
Fix #103
"User-Agent" : "zimscraperlib/3.4.0-dev0 (contact+github@openzim.org)"