def _test_sync_resources(self, object_type, plugin_type, mocked_record): plugins = self._get_all_plugins() driver = plugins[plugin_type][1] args = [mock.Mock()] if object_type in [ odl_const.ODL_BGPVPN_ROUTER_ASSOCIATION, odl_const.ODL_BGPVPN_NETWORK_ASSOCIATION ]: args.append(mock.Mock()) resources = getattr(self, self._get_name(object_type))(*args) context = mock.Mock() def _test_get_default_handler(context, resource_type, plugin_type=plugin_type): resource_type = self._get_name(resource_type)[12:] return full_sync.get_resources(context, plugin_type=plugin_type, resource_type=resource_type) handler = getattr(driver, 'get_resources', _test_get_default_handler) full_sync._sync_resources(context, object_type, handler) mocked_record.assert_has_calls([ mock.call(context, object_type, resource['id'], odl_const.ODL_CREATE, resource) for resource in resources ])
def _test_sync_resources(self, object_type, plugin_type, mocked_record): plugins = self._get_all_plugins() driver = plugins[plugin_type][1] args = [mock.Mock()] if object_type in [odl_const.ODL_MEMBER, odl_const.ODL_BGPVPN_ROUTER_ASSOCIATION, odl_const.ODL_BGPVPN_NETWORK_ASSOCIATION]: args.append(mock.Mock()) resources = getattr(self, self._get_name(object_type))(*args) context = mock.Mock() def _test_get_default_handler(context, resource_type, plugin_type=plugin_type): resource_type = self._get_name(resource_type)[12:] return full_sync.get_resources(context, plugin_type=plugin_type, resource_type=resource_type) handler = getattr(driver, 'get_resources', _test_get_default_handler) full_sync._sync_resources(context, object_type, handler) mocked_record.assert_has_calls( [mock.call(context, object_type, resource['id'], odl_const.ODL_CREATE, resource) for resource in resources])