Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_prepare_data(expected, data, mode, encoding):
assert expected[1:] == tuple(encoder.prepare_data(data, mode, encoding))[1:]
def test_prepare_data_multiple_int():
test_data = [1]
segments = encoder.prepare_data(test_data, None, None)
assert 1 == len(segments)
assert 4 == segments.bit_length
assert (1, consts.MODE_NUMERIC, None) == segments[0][1:]
def test_prepare_data_multiple_override():
test_data = [(1, consts.MODE_ALPHANUMERIC), 2]
segments = encoder.prepare_data(test_data, None, None)
assert 2 == len(segments)
assert 10 == segments.bit_length
assert (1, consts.MODE_ALPHANUMERIC, None) == segments[0][1:]
assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]
def test_prepare_data_multiple_mode_none_encoding():
test_data = [('Ä', None, consts.DEFAULT_BYTE_ENCODING), ('Ä', None, 'utf-8'),
('Ä', None, None)]
segments = encoder.prepare_data(test_data, None, None)
assert 3 == len(segments)
assert 32 == segments.bit_length
assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
assert (2, consts.MODE_BYTE, 'utf-8') == segments[1][1:]
assert segments[0] == segments[2] # Encoding detection should produce the same result as 1st tuple
def test_prepare_data_multiple_tuple():
test_data = ('a', '1')
segments = encoder.prepare_data(test_data, None, None)
assert 2 == len(segments)
assert 12 == segments.bit_length
assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]
def test_prepare_data_multiple_mode_none():
test_data = [(1, None), ('A', None)]
segments = encoder.prepare_data(test_data, None, None)
assert 2 == len(segments)
assert 10 == segments.bit_length
assert (1, consts.MODE_NUMERIC, None) == segments[0][1:]
assert (1, consts.MODE_ALPHANUMERIC, None) == segments[1][1:]
def test_prepare_data_multiple():
test_data = ['a', '1']
segments = encoder.prepare_data(test_data, None, None)
assert 2 == len(segments)
assert 12 == segments.bit_length
assert (1, consts.MODE_BYTE, consts.DEFAULT_BYTE_ENCODING) == segments[0][1:]
assert (1, consts.MODE_NUMERIC, None) == segments[1][1:]