def setUp(self):
     self.convert = ConvertMultipleFlagsReverse(source, action)
class TestMultipleFlagsReverse(unittest.TestCase):
    def setUp(self):
        self.convert = ConvertMultipleFlagsReverse(source, action)

    def test_test_input_1(self):
        self.convert._source = '010101'
        self.assertTrue(self.convert._test_input(self.convert._source))

    def test_test_input_2(self):
        self.convert._source = ''
        self.assertFalse(self.convert._test_input(self.convert._source))

    def test_test_input_3(self):
        self.convert._source = '0112011'
        self.assertFalse(self.convert._test_input(self.convert._source))

    def test_pack_result1(self):
        res = True
        msg = "message"
        value = 'True'
        wait_result = [value, 'read', [res, msg]]
        result = list(self.convert._pack_result(res, msg, value))
        self.assertEqual(wait_result, result)

    def test_pack_result2(self):
        res = False
        msg = "message"
        wait_result = [source, 'read', [res, msg]]
        result = list(self.convert._pack_result(res, msg))
        self.assertEqual(wait_result, result)

    ''' Read tests '''
    def test_bytes_to_value_1(self):
        source = '0'
        wait_result = self.convert._pack_result(True, 'Data OK', source)
        result = self.convert._bytes_to_value(source)
        self.assertEqual(result, wait_result)

    def test_bytes_to_value_2(self):
        source = 'Rqwertyu='
        wait_result = self.convert._pack_result(False, 'Not valid data: '
                                                'Rqwertyu=')
        result = self.convert._bytes_to_value(source)
        self.assertEqual(result, wait_result)

    def test_bytes_to_value_3(self):
        source = '11111'
        wait_result = self.convert._pack_result(True, 'Data OK', source)
        result = self.convert._bytes_to_value(source)
        self.assertEqual(result, wait_result)

    ''' Write tests '''
    def test_value_to_bytes_1(self):
        source = '1011001'
        wait_result = self.convert._pack_result(True, 'Data OK',
                                                'MTAwMTEwMQ==')
        result = self.convert._value_to_bytes(source)
        self.assertEqual(result, wait_result)

    def test_value_to_bytes_2(self):
        source = '1'
        wait_result = self.convert._pack_result(True, 'Data OK', 'MQ==')
        result = self.convert._value_to_bytes(source)
        self.assertEqual(result, wait_result)

    def test_value_to_bytes_3(self):
        source = '18455545'
        wait_result = self.convert._pack_result(False,
                                                'Not valid data: 18455545')
        result = self.convert._value_to_bytes(source)
        self.assertEqual(result, wait_result)