-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: command to split traffic among revisions
- Loading branch information
Showing
5 changed files
with
243 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
import typer | ||
|
||
from paka.cli.function import process_traffic_splits, validate_traffic_split | ||
|
||
|
||
def test_validate_traffic_split() -> None: | ||
# Test valid input | ||
assert validate_traffic_split("rev1=20") == ("rev1", 20) | ||
|
||
# Test missing '=' | ||
with pytest.raises(ValueError): | ||
validate_traffic_split("rev120") | ||
|
||
# Test non-numeric percentage | ||
with pytest.raises(ValueError): | ||
validate_traffic_split("rev1=twenty") | ||
|
||
# Test percentage out of range | ||
with pytest.raises(ValueError): | ||
validate_traffic_split("rev1=101") | ||
|
||
|
||
def test_process_traffic_splits() -> None: | ||
# Test valid input | ||
splits, total = process_traffic_splits(["rev1=20", "rev2=30"]) | ||
assert splits == [("rev1", 20), ("rev2", 30)] | ||
assert total == 50 | ||
|
||
# Test duplicate revisions | ||
with pytest.raises(typer.Exit): | ||
process_traffic_splits(["rev1=20", "rev1=30"]) | ||
|
||
# Test invalid split | ||
with pytest.raises(ValueError): | ||
process_traffic_splits(["rev1=20", "rev2=thirty"]) |