-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve typing and add test for warc name generator
- Loading branch information
Wesley van Lee
committed
Oct 4, 2024
1 parent
df5096f
commit 4d18b14
Showing
4 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
-e . | ||
pytest>=8.3,<8.4 | ||
freezegun==1.5.1 | ||
mypy==1.11.2 | ||
ruff==0.6.8 | ||
ruff==0.6.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import socket | ||
|
||
from freezegun import freeze_time | ||
|
||
from scrapy_webarchive.warc import generate_warc_fname | ||
|
||
|
||
@freeze_time("2024-10-04 08:27:11") | ||
def test_generate_warc_fname(monkeypatch): | ||
prefix = "rec" | ||
|
||
# Use pytest's monkeypatch to mock the return value of socket.gethostname | ||
monkeypatch.setattr(socket, "gethostname", lambda: "example.local") | ||
|
||
# Call the function | ||
warc_fname = generate_warc_fname(prefix) | ||
|
||
# Assert the result matches the expected filename | ||
assert warc_fname == "rec-20241004082711-00000-example.warc.gz" |