def test_hash_values_timedelta() -> None: """Check that hashing timedelta objects meets expectations""" value_hours = datetime.timedelta(hours=1) value_minutes = datetime.timedelta(minutes=1) hash_timedelta = hash_values(value_hours, algorithm=HashAlgorithm.SHA256) hash_minutes = hash_values(value_minutes, algorithm=HashAlgorithm.SHA256) hash_expected = "598a7ec1bbddc45b2c5887126af6524977adb08c1102d8564f0c427c3b321659" assert hash_timedelta == hash_expected != hash_minutes
def test_hash_algorithms(algorithm, value) -> None: """Check that hashes for different algorithms meet expectations""" _hash = algorithm.value(usedforsecurity=True) _hash.update(str(value).encode("utf-8")) hash_direct = _hash.hexdigest() hash_import = hash_values(value, algorithm=algorithm) assert hash_direct == hash_import