项目文件夹

文件
wehub-resource-sync 6c9c7fe7f3
CI / lint (push) Failing after 1s
CI / unit tests (push) Failing after 1s
CI / unit tests (3.13) (push) Failing after 1s
CI / integration tests (push) Failing after 1s
CI / integration tests (3.13) (push) Failing after 1s
CI / package build (push) Failing after 1s
Commit lint / pull request title (push) Has been skipped
Commit lint / commit messages (push) Failing after 1s
Docs / links (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:24:24 +08:00

30 行
771 B
Python

from __future__ import annotations
import pytest
from pydantic import ValidationError
from everos.infra.ome.gates import Counter
def test_counter_accepts_threshold() -> None:
c = Counter(threshold=5)
assert c.threshold == 5
assert c.cooldown_seconds == 0
assert c.event_field is None
def test_counter_with_bucket_field() -> None:
c = Counter(threshold=5, event_field="user_id", cooldown_seconds=120)
assert c.event_field == "user_id"
assert c.cooldown_seconds == 120
def test_counter_rejects_zero_threshold() -> None:
with pytest.raises(ValidationError):
Counter(threshold=0)
def test_counter_rejects_negative_cooldown() -> None:
with pytest.raises(ValidationError):
Counter(threshold=5, cooldown_seconds=-1)