-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a dataclass to represent batch job sizes, including light validation.
- Loading branch information
1 parent
3eb1cb2
commit 06dbf0d
Showing
2 changed files
with
62 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Literal | ||
|
||
import pytest | ||
|
||
from gempyor.batch import JobSize | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"kwargs", | ||
( | ||
{"jobs": 0, "simulations": 1, "blocks": 1}, | ||
{"jobs": 1, "simulations": 0, "blocks": 1}, | ||
{"jobs": 1, "simulations": 1, "blocks": 0}, | ||
{"jobs": 0, "simulations": 0, "blocks": 1}, | ||
{"jobs": 1, "simulations": 0, "blocks": 0}, | ||
{"jobs": 0, "simulations": 1, "blocks": 0}, | ||
{"jobs": 0, "simulations": 0, "blocks": 0}, | ||
), | ||
) | ||
def test_less_than_one_value_error( | ||
kwargs: dict[Literal["jobs", "simulations", "blocks"], int] | ||
) -> None: | ||
param = next(k for k, v in kwargs.items() if v < 1) | ||
with pytest.raises( | ||
ValueError, | ||
match=( | ||
f"^The '{param}' attribute must be greater than 0, " | ||
f"but instead was given '{kwargs.get(param)}'.$" | ||
), | ||
): | ||
JobSize(**kwargs) |