frostfs-testlib/tests/test_converters.py
Aleksei Chetaev 71b35d45c3 Fixing issues in imports after movin tests to pip install -e for testlib
Signed-off-by: Aleksei Chetaev <alex.chetaev@gmail.com>
2023-02-28 13:49:01 +01:00

46 lines
1.9 KiB
Python

from unittest import TestCase
from frostfs_testlib.utils import converting_utils
class TestConverters(TestCase):
def test_str_to_ascii_hex(self):
source_str = ""
result_str = ""
self.assertEqual(converting_utils.str_to_ascii_hex(source_str), result_str)
source_str = '"test_data" f0r ^convert*'
result_str = "22746573745f646174612220663072205e636f6e766572742a"
self.assertEqual(converting_utils.str_to_ascii_hex(source_str), result_str)
def test_ascii_hex_to_str(self):
source_str = ""
result_bytes = b""
self.assertEqual(converting_utils.ascii_hex_to_str(source_str), result_bytes)
source_str = "22746573745f646174612220663072205e636f6e766572742a"
result_bytes = b'"test_data" f0r ^convert*'
self.assertEqual(converting_utils.ascii_hex_to_str(source_str), result_bytes)
def test_process_b64_bytearray_reverse(self):
source_str = ""
result_bytes = b""
self.assertEqual(converting_utils.process_b64_bytearray_reverse(source_str), result_bytes)
source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg=="
result_bytes = b"2a747265766e6f635e207230662022617461645f7473657422"
self.assertEqual(converting_utils.process_b64_bytearray_reverse(source_str), result_bytes)
def test_process_b64_bytearray(self):
source_str = ""
result_bytes = b""
self.assertEqual(converting_utils.process_b64_bytearray(source_str), result_bytes)
source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg=="
result_bytes = b"22746573745f646174612220663072205e636f6e766572742a"
self.assertEqual(converting_utils.process_b64_bytearray(source_str), result_bytes)
def test_contract_hash_to_address(self):
source_str = "d01a381aae45f1ed181db9d554cc5ccc69c69f4e"
result_str = "NT5hJ5peVmvYdZCsFKUM5MTcEGw5TB4k89"
self.assertEqual(converting_utils.contract_hash_to_address(source_str), result_str)