mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2025-01-08 03:51:21 +00:00
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
import pytest
|
|
from typing import (
|
|
Any,
|
|
)
|
|
|
|
from staking_deposit.exceptions import ValidationError
|
|
from staking_deposit.utils.validation import (
|
|
validate_int_range,
|
|
validate_password_strength,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
'password, valid',
|
|
[
|
|
('12345678', True),
|
|
('1234567', False),
|
|
]
|
|
)
|
|
def test_validate_password_strength(password, valid):
|
|
if valid:
|
|
validate_password_strength(password=password)
|
|
else:
|
|
with pytest.raises(ValidationError):
|
|
validate_password_strength(password=password)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
'num, low, high, valid',
|
|
[
|
|
(2, 0, 4, True),
|
|
(0, 0, 4, True),
|
|
(-1, 0, 4, False),
|
|
(4, 0, 4, False),
|
|
(0.2, 0, 4, False),
|
|
('0', 0, 4, True),
|
|
('a', 0, 4, False),
|
|
]
|
|
)
|
|
def test_validate_int_range(num: Any, low: int, high: int, valid: bool) -> None:
|
|
if valid:
|
|
validate_int_range(num, low, high)
|
|
else:
|
|
with pytest.raises(ValidationError):
|
|
validate_int_range(num, low, high)
|