本文整理汇总了Python中robotide.controller.ChiefController.load_data方法的典型用法代码示例。如果您正苦于以下问题:Python ChiefController.load_data方法的具体用法?Python ChiefController.load_data怎么用?Python ChiefController.load_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robotide.controller.ChiefController
的用法示例。
在下文中一共展示了ChiefController.load_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChiefControllerTest
# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import load_data [as 别名]
class ChiefControllerTest(unittest.TestCase):
def setUp(self):
self.ctrl = ChiefController(Namespace())
self.load_observer = MessageRecordingLoadObserver()
self.suite_listener = PublisherListener(RideOpenSuite)
self.resource_listener = PublisherListener(RideOpenResource)
def tearDown(self):
self.suite_listener.unsubscribe()
self.resource_listener.unsubscribe()
def test_loading_suite_at_startup(self):
self._load(MINIMAL_SUITE_PATH)
assert_true(self.ctrl._controller is not None)
self._test_listeners([MINIMAL_SUITE_PATH], [])
def _test_listeners(self, suite_paths, resource_paths):
assert_equals(self._get_paths(self.suite_listener.data), suite_paths)
assert_equals(self._get_paths(self.resource_listener.data), resource_paths)
def _get_paths(self, data):
return [item.path for item in data]
def test_loading_resource_at_startup(self):
self._load(RESOURCE_PATH)
assert_true(self.ctrl.resources != [])
self._test_listeners([], ALL_RESOURCE_PATH_RELATED_RESOURCE_IMPORTS)
def test_loading_invalid_data_at_startup(self):
msg = "Given file 'invalid' is not a valid Robot Framework test case or resource file."
self.ctrl.load_data('invalid', self.load_observer)
assert_true(self.load_observer.finished)
assert_equals(self.load_observer.message, msg)
self._test_listeners([], [])
def _load(self, path):
self.ctrl.load_data(path, self.load_observer)
assert_true(self.load_observer.notified)
assert_true(self.load_observer.finished)
def test_loading_datafile(self):
data = self.ctrl.load_datafile(MINIMAL_SUITE_PATH, self.load_observer)
assert_true(self.load_observer.finished)
assert_true(data is not None)
self._test_listeners([MINIMAL_SUITE_PATH], [])
def test_reloading(self):
self.ctrl.new_file_project(MINIMAL_SUITE_PATH)
files1 = self.ctrl.datafiles
self.ctrl.new_file_project(MINIMAL_SUITE_PATH)
files2 = self.ctrl.datafiles
assert_true(files1 != files2)
def test_loading_resource_file(self):
resource = self.ctrl.load_resource(RESOURCE_PATH, self.load_observer)
assert_true(self.load_observer.finished)
assert_true(resource is not None)
self._test_listeners([], ALL_RESOURCE_PATH_RELATED_RESOURCE_IMPORTS)
def test_loading_invalid_datafile(self):
self.ctrl.load_datafile('invalid', self.load_observer)
assert_equals(self.load_observer.message, "Invalid data file 'invalid'.")
self._test_listeners([], [])
def test_loading_invalid_resource(self):
assert_none(self.ctrl.load_resource('invalid', self.load_observer))
assert_equals(self.load_observer.message, "Invalid resource file 'invalid'.")
self._test_listeners([], [])
def test_dirtyness(self):
self.ctrl.load_data(COMPLEX_SUITE_PATH, MessageRecordingLoadObserver())
assert_true(not self.ctrl.is_dirty())
self.ctrl.data.create_test('newnessness')
assert_true(self.ctrl.is_dirty())
def test_load_dirty_controllers(self):
self.ctrl.load_data(SUITEPATH, MessageRecordingLoadObserver())
assert_equals(len(self.ctrl._get_all_dirty_controllers()), 0)
tcf = self._find_suite_by_type(self.ctrl.data.children, TestCaseFileController)
tcf.create_test('newnessness')
assert_equals(len(self.ctrl._get_all_dirty_controllers()), 1)
self.ctrl.data.mark_dirty()
assert_equals(len(self.ctrl._get_all_dirty_controllers()), 2)
sub_dir = self._find_suite_by_type(self.ctrl.data.children, TestDataDirectoryController)
sub_dir_tcf = self._find_suite_by_type(sub_dir.children, TestCaseFileController)
sub_dir_tcf.create_test('newnessness')
assert_equals(len(self.ctrl._get_all_dirty_controllers()), 3)
def _find_suite_by_type(self, suites, type):
for child in suites:
if isinstance(child, type):
return child
return None
def test_creating_new_resource(self):
controller = self.ctrl.new_resource('somepath')
assert_equals(controller.name, 'Somepath')
def test_resource_with_same_path_is_not_added_twice(self):
#.........这里部分代码省略.........
示例2: RIDE
# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import load_data [as 别名]
class RIDE(wx.App):
def __init__(self, path=None, updatecheck=True):
self._initial_path = path
self._updatecheck = updatecheck
context.APP = self
wx.App.__init__(self, redirect=False)
def OnInit(self):
self.settings = RideSettings()
self.preferences = Preferences(self.settings)
self.namespace = Namespace(self.settings)
self._controller = ChiefController(self.namespace, self.settings)
self.frame = RideFrame(self, self._controller)
self._editor_provider = EditorProvider()
self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
context.get_core_plugins())
self._plugin_loader.enable_plugins()
self.editor = self._get_editor()
self.editor.show()
self._load_data()
self.frame.tree.populate(self.model)
self.frame.tree.set_editor(self.editor)
self._publish_system_info()
if self._updatecheck:
UpdateNotifierController(self.settings).notify_update_if_needed(UpdateDialog)
wx.CallLater(200, ReleaseNotes(self).bring_to_front)
return True
def _publish_system_info(self):
RideLogMessage(context.SYSTEM_INFO).publish()
@property
def model(self):
return self._controller
def _get_plugin_dirs(self):
return [self.settings.get_path('plugins'),
os.path.join(self.settings['install root'], 'site-plugins'),
contrib.CONTRIB_PATH]
def _get_editor(self):
from robotide.editor import EditorPlugin
for pl in self._plugin_loader.plugins:
if isinstance(pl._plugin, EditorPlugin):
return pl._plugin
def _load_data(self):
path = self._initial_path or self._get_latest_path()
if path:
with self.active_event_loop():
observer = LoadProgressObserver(self.frame)
self._controller.load_data(path, observer)
def _get_latest_path(self):
recent = self._get_recentfiles_plugin()
if not recent or not recent.recent_files:
return None
return recent.recent_files[0]
def _get_recentfiles_plugin(self):
from robotide.recentfiles import RecentFilesPlugin
for pl in self.get_plugins():
if isinstance(pl._plugin, RecentFilesPlugin):
return pl._plugin
def get_plugins(self):
return self._plugin_loader.plugins
def register_preference_panel(self, panel_class):
'''Add the given panel class to the list of known preference panels'''
self.preferences.add(panel_class)
def unregister_preference_panel(self, panel_class):
'''Remove the given panel class from the list of known preference panels'''
self.preferences.remove(panel_class)
def register_editor(self, object_class, editor_class, activate):
self._editor_provider.register_editor(object_class, editor_class,
activate)
def unregister_editor(self, object_class, editor_class):
self._editor_provider.unregister_editor(object_class, editor_class)
def activate_editor(self, object_class, editor_class):
self._editor_provider.set_active_editor(object_class, editor_class)
def get_editors(self, object_class):
return self._editor_provider.get_editors(object_class)
def get_editor(self, object_class):
return self._editor_provider.get_editor(object_class)
@contextmanager
def active_event_loop(self):
# With wxPython 2.9.1, ProgressBar.Pulse breaks if there's no active
# event loop.
# See http://code.google.com/p/robotframework-ride/issues/detail?id=798
loop = wx.EventLoop()
wx.EventLoop.SetActive(loop)
#.........这里部分代码省略.........
示例3: RIDE
# 需要导入模块: from robotide.controller import ChiefController [as 别名]
# 或者: from robotide.controller.ChiefController import load_data [as 别名]
class RIDE(wx.App):
def __init__(self, path=None):
self._initial_path = path
context.APP = self
wx.App.__init__(self, redirect=False)
def OnInit(self):
self.namespace = Namespace()
self._controller = ChiefController(self.namespace)
self.frame = RideFrame(self, self._controller)
self._editor_provider = EditorProvider()
self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
context.get_core_plugins())
self._plugin_loader.enable_plugins()
self.editor = self._get_editor()
self.editor.show()
self._load_data()
self.frame.tree.populate(self.model)
self.frame.tree.set_editor(self.editor)
self._publish_system_info()
wx.CallLater(200, self._get_release_notes().bring_to_front)
return True
def _publish_system_info(self):
RideLogMessage(context.SYSTEM_INFO).publish()
@property
def model(self):
return self._controller
def _get_plugin_dirs(self):
return [context.SETTINGS.get_path('plugins'),
os.path.join(context.SETTINGS['install root'], 'site-plugins'),
contrib.CONTRIB_PATH]
def _get_editor(self):
from robotide.editor import EditorPlugin
for pl in self._plugin_loader.plugins:
if isinstance(pl._plugin, EditorPlugin):
return pl._plugin
def _get_release_notes(self):
from .releasenotes import ReleaseNotesPlugin
for pl in self._plugin_loader.plugins:
if isinstance(pl._plugin, ReleaseNotesPlugin):
return pl._plugin
def _load_data(self):
if self._initial_path:
with self.active_event_loop():
observer = LoadProgressObserver(self.frame)
self._controller.load_data(self._initial_path, observer)
def get_plugins(self):
return self._plugin_loader.plugins
def register_editor(self, object_class, editor_class, activate):
self._editor_provider.register_editor(object_class, editor_class,
activate)
def unregister_editor(self, object_class, editor_class):
self._editor_provider.unregister_editor(object_class, editor_class)
def activate_editor(self, object_class, editor_class):
self._editor_provider.set_active_editor(object_class, editor_class)
def get_editors(self, object_class):
return self._editor_provider.get_editors(object_class)
def get_editor(self, object_class):
return self._editor_provider.get_editor(object_class)
@contextmanager
def active_event_loop(self):
# With wxPython 2.9.1, ProgressBar.Pulse breaks if there's no active
# event loop.
# See http://code.google.com/p/robotframework-ride/issues/detail?id=798
loop = wx.EventLoop()
wx.EventLoop.SetActive(loop)
yield
del loop