~sbaldassin/autopilot/fix_mir

« back to all changes in this revision

Viewing changes to autopilot/tests/unit/test_introspection_dbus.py

Allow Custom Proxy Object classes to have a different name to that of the underlying UI Type. Fixes: https://bugs.launchpad.net/bugs/1337004.

Approved by PS Jenkins bot, Max Brustkern.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
                ),
119
119
            )
120
120
 
 
121
    def test_base_class_provides_correct_query_name(self):
 
122
        self.assertThat(
 
123
            dbus.DBusIntrospectionObject.get_type_query_name(),
 
124
            Equals('ProxyBase')
 
125
        )
 
126
 
 
127
    def test_inherited_uses_default_get_node_name(self):
 
128
        class TestCPO(dbus.DBusIntrospectionObject):
 
129
            pass
 
130
 
 
131
        self.assertThat(
 
132
            TestCPO.get_type_query_name(),
 
133
            Equals('TestCPO')
 
134
        )
 
135
 
 
136
    def test_inherited_overwrites_node_name_is_correct(self):
 
137
        class TestCPO(dbus.DBusIntrospectionObject):
 
138
            @classmethod
 
139
            def get_type_query_name(cls):
 
140
                return "TestCPO"
 
141
        self.assertThat(TestCPO.get_type_query_name(), Equals("TestCPO"))
 
142
 
121
143
 
122
144
class ProxyObjectPrintTreeTests(TestCase):
123
145
 
222
244
        class FooBarBaz(object):
223
245
            pass
224
246
        self.assertEqual("FooBarBaz", dbus.get_type_name(FooBarBaz))
 
247
 
 
248
    def test_get_type_name_returns_classname(self):
 
249
        class CustomCPO(dbus.DBusIntrospectionObject):
 
250
            pass
 
251
 
 
252
        type_name = dbus.get_type_name(CustomEmulatorBase)
 
253
        self.assertThat(type_name, Equals('ProxyBase'))
 
254
 
 
255
    def test_get_type_name_returns_custom_node_name(self):
 
256
        class CustomCPO(dbus.DBusIntrospectionObject):
 
257
            @classmethod
 
258
            def get_type_query_name(cls):
 
259
                return 'TestingCPO'
 
260
        type_name = dbus.get_type_name(CustomCPO)
 
261
        self.assertThat(type_name, Equals('TestingCPO'))
 
262
 
 
263
    def test_get_type_name_returns_classname_of_non_proxybase_classes(self):
 
264
        class Foo(object):
 
265
            pass
 
266
        self.assertEqual('Foo', dbus.get_type_name(Foo))