mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Fixes comments, docstrings and some renamings
This commit is contained in:
@@ -3,9 +3,9 @@ import logging
|
||||
|
||||
from common.constants import LOCATOR_LEN_BYTES
|
||||
from common.tools import (
|
||||
check_compressed_pk_format,
|
||||
check_sha256_hex_format,
|
||||
check_locator_format,
|
||||
is_compressed_pk,
|
||||
is_256b_hex_str,
|
||||
is_locator,
|
||||
compute_locator,
|
||||
setup_data_folder,
|
||||
setup_logging,
|
||||
@@ -13,7 +13,7 @@ from common.tools import (
|
||||
from test.common.unit.conftest import get_random_value_hex
|
||||
|
||||
|
||||
def test_check_compressed_pk_format():
|
||||
def test_is_compressed_pk():
|
||||
wrong_values = [
|
||||
None,
|
||||
3,
|
||||
@@ -34,21 +34,21 @@ def test_check_compressed_pk_format():
|
||||
prefix = "02"
|
||||
else:
|
||||
prefix = "03"
|
||||
assert check_compressed_pk_format(prefix + get_random_value_hex(32))
|
||||
assert is_compressed_pk(prefix + get_random_value_hex(32))
|
||||
|
||||
# check_user_pk must only accept values that is not a 33-byte hex string
|
||||
for value in wrong_values:
|
||||
assert not check_compressed_pk_format(value)
|
||||
assert not is_compressed_pk(value)
|
||||
|
||||
|
||||
def test_check_sha256_hex_format():
|
||||
def test_is_256b_hex_str():
|
||||
# Only 32-byte hex encoded strings should pass the test
|
||||
wrong_inputs = [None, str(), 213, 46.67, dict(), "A" * 63, "C" * 65, bytes(), get_random_value_hex(31)]
|
||||
for wtype in wrong_inputs:
|
||||
assert check_sha256_hex_format(wtype) is False
|
||||
assert is_256b_hex_str(wtype) is False
|
||||
|
||||
for v in range(100):
|
||||
assert check_sha256_hex_format(get_random_value_hex(32)) is True
|
||||
assert is_256b_hex_str(get_random_value_hex(32)) is True
|
||||
|
||||
|
||||
def test_check_locator_format():
|
||||
@@ -66,20 +66,20 @@ def test_check_locator_format():
|
||||
get_random_value_hex(LOCATOR_LEN_BYTES - 1),
|
||||
]
|
||||
for wtype in wrong_inputs:
|
||||
assert check_locator_format(wtype) is False
|
||||
assert is_locator(wtype) is False
|
||||
|
||||
for _ in range(100):
|
||||
assert check_locator_format(get_random_value_hex(LOCATOR_LEN_BYTES)) is True
|
||||
assert is_locator(get_random_value_hex(LOCATOR_LEN_BYTES)) is True
|
||||
|
||||
|
||||
def test_compute_locator():
|
||||
# The best way of checking that compute locator is correct is by using check_locator_format
|
||||
# The best way of checking that compute locator is correct is by using is_locator
|
||||
for _ in range(100):
|
||||
assert check_locator_format(compute_locator(get_random_value_hex(LOCATOR_LEN_BYTES))) is True
|
||||
assert is_locator(compute_locator(get_random_value_hex(LOCATOR_LEN_BYTES))) is True
|
||||
|
||||
# String of length smaller than LOCATOR_LEN_BYTES bytes must fail
|
||||
for i in range(1, LOCATOR_LEN_BYTES):
|
||||
assert check_locator_format(compute_locator(get_random_value_hex(i))) is False
|
||||
assert is_locator(compute_locator(get_random_value_hex(i))) is False
|
||||
|
||||
|
||||
def test_setup_data_folder():
|
||||
|
||||
Reference in New Issue
Block a user