class Test(IonUnitTestCase):

    def setUp(self):
        self._cgsn_state = CgsnState()
        self._cc = CGSNClientFactory.create_instance()
        self._cc.set_listener(self._cgsn_state.listener)
        self._cc.start()

    def tearDown(self):
        self._cc.end_reception()

    def test_some_acks_nacks(self):

        dcl_id = DclIds.DCL11
        cmd_nas = [
            # command,                         expected NACK or ACK
            (MessageIds.DCL_STATUS,            MessageIds.ACK),
            ("%s 1 1" % MessageIds.PORT_ONOFF, MessageIds.ACK),
            ("%s 0 1" % MessageIds.PORT_ONOFF, MessageIds.NACK),
            ("%s 3 1" % MessageIds.PORT_ONOFF, MessageIds.ACK),
        ]

        for cmd, na in cmd_nas:
            self._cc.send_command(dcl_id, cmd)

            # TODO instead of sleep, use AsyncResult or similar mechanism
            sleep(1)

            ack_nack = self._cgsn_state.get_ack_nack(dcl_id, cmd)
            self.assertEquals(na, ack_nack)
class Test(IonUnitTestCase):

    def setUp(self):
        self._cgsn_state = CgsnState()
        self._cc = CGSNClientFactory.create_instance()
        self._cc.set_listener(self._cgsn_state.listener)
        self._cc.start()

    def tearDown(self):
        self._cc.end_reception()

    def test_some_acks_nacks(self):

        dcl_id = DclIds.DCL11
        cmd_nas = [
            # command,                         expected NACK or ACK
            (MessageIds.DCL_STATUS,            MessageIds.ACK),
            ("%s 1 1" % MessageIds.PORT_ONOFF, MessageIds.ACK),
            ("%s 0 1" % MessageIds.PORT_ONOFF, MessageIds.NACK),
            ("%s 3 1" % MessageIds.PORT_ONOFF, MessageIds.ACK),
        ]

        for cmd, na in cmd_nas:
            self._cc.send_command(dcl_id, cmd)

            # TODO instead of sleep, use AsyncResult or similar mechanism
            sleep(1)

            ack_nack = self._cgsn_state.get_ack_nack(dcl_id, cmd)
            self.assertEquals(na, ack_nack)
class Test(IonUnitTestCase):

    def setUp(self):
        self._cgsn_state = CgsnState()
        self._cc = CGSNClientFactory.create_instance()
        self._cc.set_listener(self._cgsn_state.listener)
        self._cc.start()

    def tearDown(self):
        self._cc.end_reception()

    def test_get_dcl_status(self):

        dcl_id = DclIds.DCL11
        cmd = MessageIds.DCL_STATUS
        self._cc.send_command(dcl_id, cmd)

        # TODO instead of sleep, use AsyncResult or similar mechanism
        sleep(2)

        ack_nack = self._cgsn_state.get_ack_nack(dcl_id, cmd)
        self.assertTrue(MessageIds.ACK, ack_nack)
 def setUp(self):
     self._cgsn_state = CgsnState()
     self._cc = CGSNClientFactory.create_instance()
     self._cc.set_listener(self._cgsn_state.listener)
     self._cc.start()
 def setUp(self):
     self._cgsn_state = CgsnState()
     self._cc = CGSNClientFactory.create_instance()
     self._cc.set_listener(self._cgsn_state.listener)
     self._cc.start()