-
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.
This ends up giving us a 1.5x speed improvement ``` ❯ hyperfine --warmup 1 ".\old\Scripts\python.exe test_nzb_old.py" ".\.venv\Scripts\python.exe test_nzb.py" Benchmark 1: .\old\Scripts\python.exe test_nzb_old.py Time (mean ± σ): 6.042 s ± 0.295 s [User: 5.752 s, System: 0.259 s] Range (min … max): 5.754 s … 6.413 s 10 runs Benchmark 2: .\.venv\Scripts\python.exe test_nzb.py Time (mean ± σ): 3.902 s ± 0.019 s [User: 3.624 s, System: 0.222 s] Range (min … max): 3.871 s … 3.930 s 10 runs Summary .\.venv\Scripts\python.exe test_nzb.py ran 1.55 ± 0.08 times faster than .\old\Scripts\python.exe test_nzb_old.py ```
- Loading branch information
1 parent
0846a73
commit d17e8b1
Showing
8 changed files
with
119 additions
and
145 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
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
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,13 +1,7 @@ | ||
from __future__ import annotations | ||
|
||
from datetime import datetime, timezone | ||
from os import PathLike | ||
from typing import Annotated, TypeAlias | ||
|
||
from pydantic import AfterValidator | ||
from typing import TypeAlias | ||
|
||
StrPath: TypeAlias = str | PathLike[str] | ||
"""String or pathlib.Path""" | ||
|
||
UTCDateTime = Annotated[datetime, AfterValidator(lambda dt: dt.astimezone(timezone.utc))] | ||
"""datetime that's always in UTC.""" |
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,5 +1,6 @@ | ||
from __future__ import annotations | ||
|
||
import textwrap | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
@@ -105,3 +106,30 @@ def test_read_nzb_file(tmp_path: Path) -> None: | |
|
||
with pytest.raises(InvalidNzbError, match="^Failed to read NZB file"): | ||
read_nzb_file(tmp_file) | ||
|
||
|
||
def test_nzb_with_missing_file_attributes() -> None: | ||
nzb = textwrap.dedent(""" | ||
<?xml version="1.0" encoding="iso-8859-1" ?> | ||
<!DOCTYPE nzb PUBLIC "-//newzBin//DTD NZB 1.1//EN" "http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd"> | ||
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb"> | ||
<head> | ||
<meta type="title">Your File!</meta> | ||
<meta type="password">secret</meta> | ||
<meta type="tag">HD</meta> | ||
<meta type="category">TV</meta> | ||
</head> | ||
<file poster="Joe Bloggs <[email protected]>" date="not a date" subject="Here's your file! abc-mr2a.r01 (1/2)"> | ||
<groups> | ||
<group>alt.binaries.newzbin</group> | ||
<group>alt.binaries.mojo</group> | ||
</groups> | ||
<segments> | ||
<segment bytes="102394" number="1">[email protected]</segment> | ||
<segment bytes="4501" number="2">[email protected]</segment> | ||
</segments> | ||
</file> | ||
</nzb> | ||
""").strip() | ||
with pytest.raises(InvalidNzbError, match=r"Invalid RFC3339 encoded datetime - at `\$\.posted_at`"): | ||
Nzb.from_str(nzb) |
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
Oops, something went wrong.