def test_write_byte_arg_to_string(regtest): """Tests writing different varients of bytes to the write byte cmd""" args_list = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (0x100, 4), (0x10000, 4), (0x1000000, 4), (0x100000000, 5), (0x10000000000, 6), (0x1000000000000, 7), (0x100000000000000, 8), ([1, 2, 3, 4], 0), ([1, 2], 0), ([1, 2, 3], 0), ([1, 2, 3, 4, 5], 0), ([1, 2, 3, 4, 6, 7, 8, 9, 10], 0), ([1, 0, 0, 0], 0)] for args in args_list: result = PhilipBaseIf()._write_byte_arg_to_string(*args) regtest.write('data={}, size={}, result="{}"\n'.format( args[0], args[1], result))
def phil_init_base(): phil = PhilipBaseIf() yield phil phil.dev.close()
def test_try_data_to_int(byte_list, expected): """Tests turning data from cmd_info to int""" cmd_info = {'data': byte_list} PhilipBaseIf()._try_data_to_int(cmd_info) assert cmd_info['data'] == expected
def test_bytes_to_int(byte_list, expected): """Tests byte list to int""" assert PhilipBaseIf()._bytes_to_int(byte_list) == expected