24 lines
674 B
Python
24 lines
674 B
Python
import pytest
|
|
|
|
from algorithms import Algorithm, get_algorithm
|
|
|
|
|
|
def test_algorithm_has_required_methods():
|
|
"""Verify Algorithm protocol defines required methods."""
|
|
algo = get_algorithm("pbkdf2")
|
|
assert hasattr(algo, "hash")
|
|
assert hasattr(algo, "verify")
|
|
assert hasattr(algo, "identifier")
|
|
|
|
|
|
def test_get_algorithm_returns_pbkdf2():
|
|
"""Verify default algorithm is PBKDF2."""
|
|
algo = get_algorithm("pbkdf2")
|
|
assert algo.identifier == "pbkdf2"
|
|
|
|
|
|
def test_get_algorithm_unknown_raises_error():
|
|
"""Verify unknown algorithm raises ValueError."""
|
|
with pytest.raises(ValueError, match="Unknown algorithm"):
|
|
get_algorithm("unknown")
|