Example #1
0
 def setUp(self):
     self.endpoint = _StringEndpoint()
     self.device = Controller(
         reactor=the_reactor,
         endpoint=self.endpoint,
         elements=[
             Command('cmd_name', 'cmd_text'),
             Command('unicode_cmd', u'façade'),
             Selector('enum_name', Enum({u'enum_text1': u'enum_label1', u'enum_text2': u'enum_label2'}, strict=False))
         ],
         encoding='UTF-8')
     self.proxy = self.device.get_components_dict()['controller']
Example #2
0
class TestController(unittest.TestCase):
    """
    Also contains generic proxy tests.
    """
    timeout = 5

    def setUp(self):
        self.endpoint = StringTransportEndpoint()
        self.t = self.endpoint.string_transport
        self.device = Controller(reactor=the_reactor,
                                 endpoint=self.endpoint,
                                 elements=[
                                     Command('cmd_name', 'cmd_text'),
                                     Command('unicode_cmd', u'façade'),
                                     Selector(
                                         'enum_name',
                                         EnumT(
                                             {
                                                 u'enum_text1': u'enum_label1',
                                                 u'enum_text2': u'enum_label2'
                                             },
                                             strict=False))
                                 ],
                                 encoding='UTF-8')
        self.proxy = self.device.get_components_dict()['controller']

    @defer.inlineCallbacks
    def tearDown(self):
        yield self.device.close()
        yield self.proxy.close(
        )  # TODO kludge because device close doesn't actually work for our purposes

    def test_state_smoke(self):
        state_smoke_test(self.device)

    def test_send_command(self):
        self.proxy.state()['cmd_name'].set(True)  # TODO command-cell kludge
        self.assertEqual('cmd_text', self.t.value())

    def test_send_enum(self):
        self.proxy.state()['enum_name'].set('enum_text1')
        self.t.clear()
        self.proxy.state()['enum_name'].set('enum_text2')
        self.assertEqual('enum_text2', self.t.value())

    def test_encode_command(self):
        self.proxy.state()['unicode_cmd'].set(True)  # TODO command-cell kludge
        self.assertEqual(u'façade'.encode('UTF-8'), self.t.value())

    def test_encode_enum(self):
        self.proxy.state()['enum_name'].set(u'façade')
        self.assertEqual(u'façade'.encode('UTF-8'), self.t.value())
Example #3
0
class TestController(unittest.TestCase):
    """
    Also contains generic proxy tests.
    """
    timeout = 5
    
    def setUp(self):
        self.endpoint = StringTransportEndpoint()
        self.t = self.endpoint.string_transport
        self.device = Controller(
            reactor=the_reactor,
            endpoint=self.endpoint,
            elements=[
                Command('cmd_name', 'cmd_text'),
                Command('unicode_cmd', u'façade'),
                Selector('enum_name', EnumT({u'enum_text1': u'enum_label1', u'enum_text2': u'enum_label2'}, strict=False))
            ],
            encoding='UTF-8')
        self.proxy = self.device.get_components_dict()['controller']
    
    @defer.inlineCallbacks
    def tearDown(self):
        yield self.device.close()
        self.assertTrue(self.t.disconnecting)
    
    def test_state_smoke(self):
        state_smoke_test(self.device)
    
    def test_send_command(self):
        self.proxy.state()['cmd_name'].set(True)  # TODO command-cell kludge
        self.assertEqual(b'cmd_text', self.t.value())
    
    def test_send_enum(self):
        self.proxy.state()['enum_name'].set('enum_text1')
        self.t.clear()
        self.proxy.state()['enum_name'].set('enum_text2')
        self.assertEqual(b'enum_text2', self.t.value())
    
    def test_encode_command(self):
        self.proxy.state()['unicode_cmd'].set(True)  # TODO command-cell kludge
        self.assertEqual(u'façade'.encode('UTF-8'), self.t.value())
    
    def test_encode_enum(self):
        self.proxy.state()['enum_name'].set(u'façade')
        self.assertEqual(u'façade'.encode('UTF-8'), self.t.value())
Example #4
0
 def setUp(self):
     self.endpoint = _StringEndpoint()
     self.device = Controller(
         reactor=the_reactor,
         endpoint=self.endpoint,
         elements=[
             Command('cmd_name', 'cmd_text'),
             Command('unicode_cmd', u'façade'),
             Selector('enum_name', EnumT({u'enum_text1': u'enum_label1', u'enum_text2': u'enum_label2'}, strict=False))
         ],
         encoding='UTF-8')
     self.proxy = self.device.get_components_dict()['controller']