def setUp(self):
   self.tesIntf = TesInterface()
class ProtocolTestCase(unittest.TestCase):
  """Unit tests for googlemaps."""

  def setUp(self):
    self.tesIntf = TesInterface()

  def tearDown(self):
    self.tesIntf.dispose()
    self.tesIntf = None

  def test_Err0InvalidCommand(self):
    """Controllo la lunghezza del comando passato"""
    self.assertRegexpMatches(self.tesIntf.parseCommand(''),r'^CERR .* 0: lunghezza comando non valida$')

  def test_CT1Err1NoParameters(self):
    """Controllo che siano stati accodati sufficienti parametri"""
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1"),r'^CERR .* 1: nessun parametro inviato$')
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 A0.00"),r'^CERR .* 1: nessun parametro inviato$')
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 A0.00 B0.00"),r'^CERR .* 1: nessun parametro inviato$')

  def test_CT1Err2WrongR(self):
    """Controllo che sia corretto il parametro R"""
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 A0.00 Y0.00 K0.00"),r'^CERR .* 2: parametro .* non valido, atteso R$')

  def test_CT1Err2WrongP(self):
    """Controllo che sia corretto il parametro P"""
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 R0.00 Y0.00 K0.00"),r'^CERR .* 3: parametro .* non valido, atteso P$')

  def test_CT1Err2WrongY(self):
    """Controllo che sia corretto il parametro Y"""
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 R0.00 P0.00 K0.00"),r'^CERR .* 4: parametro .* non valido, atteso Y$')

  def test_CT1Err2WrongVorT(self):
    """Controllo che sia corretto il parametro V o T se presenti"""
    self.assertRegexpMatches(self.tesIntf.parseCommand("CT1 R0.00 P0.00 Y0.00 K213"),r'^CERR .* 5: parametro .* non valido, atteso V o T$')

  def test_CT1(self):
    """Controllo la corretta ricezione di un comando CT1 valido"""
    self.assertEqual(self.tesIntf.parseCommand("CT1 R0.00 P0.00 Y0.00 V213"),"OK")
    self.assertEqual(self.tesIntf.parseCommand("CT1 R0.00 P0.00 Y0.00 T12.21"),"OK")