Example #1
0
 def setUp(self):
     self.server = LantopEmulator(resp_dict=TEST_DATA)
     self.server.start()
     self.tp = Transport(*self.server.server_address)
Example #2
0
class LantopTransportTest(unittest.TestCase):

    def setUp(self):
        self.server = LantopEmulator(resp_dict=TEST_DATA)
        self.server.start()
        self.tp = Transport(*self.server.server_address)

    def tearDown(self):
        self.tp.close()
        self.server.stop()

    def test_command_error_code(self):
        with self.assertRaises(LantopError) as cm:
            self.tp.command("xxxxxx0", "xx")
        self.assertEqual("Got unknown error code", str(cm.exception))

    def test_request_channel_wrong(self):
        with self.assertRaises(LantopError) as cm:
            self.tp.request("xxxxxx0", "xx", channel=9)
        self.assertEqual("Invalid channel index given", str(cm.exception))

    def test_command_error_code2(self):
        with self.assertRaises(LantopError) as cm:
            self.tp.command("xxxxxx1", "xx")
        self.assertEqual("Got UNGUELTIGER BEFEHL", str(cm.exception))

    def test_command_decode(self):
        with self.assertRaises(LantopError) as cm:
            self.tp.command("xxxxxx2", "xx")
        self.assertEqual("Message can not be decoded", str(cm.exception))

    def test_command_resp_code(self):
        with self.assertRaises(LantopError) as cm:
            self.tp.command("xxxxxx0", "xy")
        self.assertEqual("Wrong response code", str(cm.exception))