~nskaggs/autopilot/add-click-rule

« back to all changes in this revision

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

Fix proxy creation for the root of the introspection tree. Fixes: https://bugs.launchpad.net/bugs/1306330, https://bugs.launchpad.net/bugs/1348399.

Approved by Christopher Lee, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        gpoc_return = object_registry._get_proxy_object_class(
65
65
            "fake_id",  # cannot set to none.
66
66
            None,
67
 
            None,
68
67
            None
69
68
        )
70
69
 
78
77
        class_dict = {'DefaultSelector': self.DefaultSelector}
79
78
        path = '/path/to/DefaultSelector'
80
79
        state = {}
81
 
        object_registry._get_proxy_object_class(class_dict, None, path, state)
 
80
        object_registry._get_proxy_object_class(class_dict, path, state)
82
81
        tcpc.assert_called_once_with(class_dict, path, state)
83
82
 
84
83
    @patch.object(object_registry, '_try_custom_proxy_classes')
90
89
            lambda: object_registry._get_proxy_object_class(
91
90
                "None",  # Cannot be set to None, but don't care about value
92
91
                None,
93
 
                None,
94
92
                None
95
93
            ),
96
94
            raises(ValueError))
102
100
        """_get_proxy_object_class should call _get_default_proxy_class if
103
101
        _try_custom_proxy_classes returns None."""
104
102
        tcpc.return_value = None
105
 
        object_registry._get_proxy_object_class(None, None, None, None)
 
103
        object_registry._get_proxy_object_class(None, None, None)
106
104
        self.assertTrue(gdpc.called)
107
105
 
108
106
    @patch.object(object_registry, '_try_custom_proxy_classes')
111
109
        """_get_proxy_object_class should pass the correct arguments to
112
110
        _get_default_proxy_class"""
113
111
        tcpc.return_value = None
114
 
        default = self.DefaultSelector
 
112
        obj_id = 123
115
113
        path = '/path/to/DefaultSelector'
116
 
        object_registry._get_proxy_object_class(None, default, path, None)
 
114
        object_registry._get_proxy_object_class(obj_id, path, None)
117
115
        gdpc.assert_called_once_with(
118
 
            default,
 
116
            obj_id,
119
117
            xpathselect.get_classname_from_path(path)
120
118
        )
121
119
 
132
130
            None,
133
131
            None,
134
132
            None,
135
 
            None
136
133
        )
137
134
        self.assertThat(gpoc_return, Equals(token))
138
135