本文整理汇总了Python中robotide.controller.ChiefController类的典型用法代码示例。如果您正苦于以下问题:Python ChiefController类的具体用法?Python ChiefController怎么用?Python ChiefController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChiefController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deleting_init_file
def test_deleting_init_file(self):
chief = ChiefController(Namespace())
chief._controller = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate(), chief)
os.remove(self._init_path)
chief.data.remove()
open(self._init_path, 'w').write('*Settings*\nDocumentation Ride unit testing file\n')
assert_true(chief.data.has_format() is False, chief.data.data.initfile)
示例2: TestFindingControllers
class TestFindingControllers(unittest.TestCase):
def setUp(self):
self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings(), _library_manager())
def tearDown(self):
self.chief.close()
def test_finding_root_directory_controller(self):
self.chief._controller = TestDataDirectoryController(_data_directory('Root'))
result = self.chief.find_controller_by_longname('Root')
assert_equals(result, self.chief._controller)
def test_finding_subdirectory_controller(self):
directory_controller = TestDataDirectoryController(_data_directory('Root'))
subdirectory_controller = TestDataDirectoryController(_data_directory('Subsuite'))
directory_controller.add_child(subdirectory_controller)
self.chief._controller = directory_controller
result = self.chief.find_controller_by_longname('Root.Subsuite')
assert_equals(result, subdirectory_controller)
def test_finding_testcase_controller(self):
suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
test = suite_controller.create_test('Test 1')
self.chief._controller = suite_controller
result = self.chief.find_controller_by_longname('Suite.Test 1')
assert_equals(result, test)
示例3: TestCaseControllerWithSteps
def TestCaseControllerWithSteps(chief=None, source='some_suite.txt'):
tcf = TestCaseFile()
tcf.source = source
tcf.setting_table.suite_setup.name = 'Suite Setup Kw'
tcf.setting_table.test_setup.name = SUITE_TEST_SETUP_KEYWORD
tcf.setting_table.test_teardown.name = 'Test Teardown Kw'
tcf.setting_table.suite_teardown.name = 'Suite Teardown Kw'
tcf.setting_table.test_template.value = SUITE_TEST_TEMPLATE_KEYWORD
testcase = tcf.testcase_table.add(TEST1_NAME)
for step in [[STEP1_KEYWORD, 'Hello'], ['Run Keyword', STEP2_ARGUMENT], [USERKEYWORD2_NAME]]:
testcase.add_step(step)
for_loop = testcase.add_for_loop([': FOR', '${i}', 'IN RANGE', '10'])
for_loop.add_step(['Log', '${i}'])
testcase.setup.name = SETUP_KEYWORD
testcase.teardown.name = 'Teardown Kw'
testcase.template.value = TEMPLATE_KEYWORD
uk = tcf.keyword_table.add(USERKEYWORD1_NAME)
uk.add_step([KEYWORD_IN_USERKEYWORD1])
uk = tcf.keyword_table.add(USERKEYWORD2_NAME)
uk.add_step(['No Operation'])
if chief is None:
chief = ChiefController(Namespace())
tcf_ctrl = TestCaseFileController(tcf, chief)
chief._controller = tcf_ctrl
tctablectrl = TestCaseTableController(tcf_ctrl,
tcf.testcase_table)
return TestCaseController(tctablectrl, testcase), chief._namespace
示例4: test_deleting_source_should_remove_it_from_model
def test_deleting_source_should_remove_it_from_model(self):
chief = ChiefController(Namespace())
chief._controller = TestCaseFileController(TestCaseFile(source=self._filepath), chief)
os.remove(self._filepath)
ctrl = chief.data
ctrl.remove()
assert_true(chief.data is None)
assert_true(self._removed_datafile is ctrl)
示例5: TestFindingControllers
class TestFindingControllers(unittest.TestCase):
def setUp(self):
self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings(), _library_manager())
def tearDown(self):
self.chief.close()
def test_finding_root_directory_controller(self):
self.chief._controller = TestDataDirectoryController(_data_directory('Root'))
result = self.chief.find_controller_by_longname('Root')
assert_equals(result, self.chief._controller)
def test_finding_subdirectory_controller(self):
directory_controller = TestDataDirectoryController(_data_directory('Root'))
subdirectory_controller = TestDataDirectoryController(_data_directory('Sub.suite'))
directory_controller.add_child(subdirectory_controller)
self.chief._controller = directory_controller
result = self.chief.find_controller_by_longname('Root.Sub.suite')
assert_equals(result, subdirectory_controller)
def test_finding_testcase_controller(self):
suite_controller = TestCaseFileController(_testcasefile('Suite.txt'))
test = suite_controller.create_test('Test 1')
self.chief._controller = suite_controller
result = self.chief.find_controller_by_longname('Suite.Test 1', 'Test 1')
assert_equals(result, test)
def test_finding_correct_testcase_when_two_with_same_name(self):
test1, test2 = self._create_suite_structure_with_two_tests_with_same_name()
result1 = self.chief.find_controller_by_longname('Ro.ot.'+test1.longname, test1.display_name)
assert_equals(result1, test1)
result2 = self.chief.find_controller_by_longname('Ro.ot.'+test2.longname, test2.display_name)
assert_equals(result2, test2)
def test_finding_correct_testcase_when_two_files_with_same_name_start(self):
directory_controller = TestDataDirectoryController(_data_directory('t'))
suite1_controller = TestCaseFileController(_testcasefile('test.txt'))
test1 = suite1_controller.create_test('A')
suite2_controller = TestCaseFileController(_testcasefile('test2.txt'))
test2 = suite2_controller.create_test('A')
directory_controller.add_child(suite1_controller)
directory_controller.add_child(suite2_controller)
self.chief._controller = directory_controller
result1 = self.chief.find_controller_by_longname('T.'+test1.longname, test1.display_name)
assert_equals(result1, test1)
result2 = self.chief.find_controller_by_longname('T.'+test2.longname, test2.display_name)
assert_equals(result2, test2)
def _create_suite_structure_with_two_tests_with_same_name(self):
directory_controller = TestDataDirectoryController(_data_directory('Ro.ot'))
suite1_controller = TestCaseFileController(_testcasefile('Suite.1.txt'))
test1 = suite1_controller.create_test('Te.st')
suite2_controller = TestCaseFileController(_testcasefile('Suite.2.txt'))
test2 = suite2_controller.create_test('Te.st')
directory_controller.add_child(suite1_controller)
directory_controller.add_child(suite2_controller)
self.chief._controller = directory_controller
return test1, test2
示例6: TestCaseControllerWithSteps
def TestCaseControllerWithSteps(chief=None, source="some_suite.txt"):
tcf = TestCaseFile()
tcf.source = source
tcf.setting_table.suite_setup.name = "Suite Setup Kw"
tcf.setting_table.test_setup.name = SUITE_TEST_SETUP_KEYWORD
tcf.setting_table.test_teardown.name = "Test Teardown Kw"
tcf.setting_table.suite_teardown.name = "Suite Teardown Kw"
tcf.setting_table.test_template.value = SUITE_TEST_TEMPLATE_KEYWORD
testcase = _create_testcase(tcf)
uk = tcf.keyword_table.add(USERKEYWORD1_NAME)
uk.add_step([KEYWORD_IN_USERKEYWORD1])
uk = tcf.keyword_table.add(USERKEYWORD2_NAME)
uk.add_step(["No Operation"])
uk = tcf.keyword_table.add(EMBEDDED_ARGUMENTS_KEYWORD)
uk.add_step(["No Operation"])
if chief is None:
chief = ChiefController(Namespace(FakeSettings()))
tcf_ctrl = TestCaseFileController(tcf, chief)
chief._controller = tcf_ctrl
tctablectrl = TestCaseTableController(tcf_ctrl, tcf.testcase_table)
return TestCaseController(tctablectrl, testcase), chief._namespace
示例7: TestCaseControllerWithSteps
def TestCaseControllerWithSteps(chief=None, source='some_suite.txt'):
tcf = TestCaseFile()
tcf.source = source
tcf.setting_table.suite_setup.name = 'Suite Setup Kw'
tcf.setting_table.test_setup.name = SUITE_TEST_SETUP_KEYWORD
tcf.setting_table.test_teardown.name = 'Test Teardown Kw'
tcf.setting_table.suite_teardown.name = 'Suite Teardown Kw'
tcf.setting_table.test_template.value = SUITE_TEST_TEMPLATE_KEYWORD
testcase = _create_testcase(tcf)
uk = tcf.keyword_table.add(USERKEYWORD1_NAME)
uk.add_step([KEYWORD_IN_USERKEYWORD1])
uk = tcf.keyword_table.add(USERKEYWORD2_NAME)
uk.add_step(['No Operation'])
uk = tcf.keyword_table.add(EMBEDDED_ARGUMENTS_KEYWORD)
uk.add_step(['No Operation'])
if chief is None:
library_manager = LibraryManager(':memory:')
library_manager.create_database()
chief = ChiefController(Namespace(FakeSettings()), library_manager=library_manager)
tcf_ctrl = TestCaseFileController(tcf, chief)
chief._controller = tcf_ctrl
tctablectrl = TestCaseTableController(tcf_ctrl,
tcf.testcase_table)
return TestCaseController(tctablectrl, testcase), chief._namespace
示例8: OnInit
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
示例9: OnInit
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
示例10: setUp
def setUp(self):
self.chief = ChiefController(Namespace(FakeSettings()), FakeSettings())
示例11: RIDE
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)
#.........这里部分代码省略.........
示例12: setUp
def setUp(self):
self.ctrl = ChiefController(Namespace())
self.load_observer = MessageRecordingLoadObserver()
self.suite_listener = PublisherListener(RideOpenSuite)
self.resource_listener = PublisherListener(RideOpenResource)
示例13: ChiefControllerTest
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):
#.........这里部分代码省略.........
示例14: TestResolvingResourceDirectories
class TestResolvingResourceDirectories(unittest.TestCase):
def setUp(self):
self.chief = ChiefController(Namespace())
def test_resource_file_outside_of_topsuite_is_an_external_resource(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('suite'))
self._set_resources(j('foo','resource.txt'))
assert_equals(self.chief.external_resources, self.chief.resources)
def test_resource_file_in_own_directory_is_added_to_top_suite(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('foo'))
self._set_resources(j('foo','bar','quux.txt'))
self._assert_resource_dir_was_created_as_child_of(self.chief.data)
self._assert_resource_dir_contains_resources()
assert_true(len(self.chief.external_resources)== 0)
def test_two_resource_in_same_directory_get_same_parent(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('foo'))
self._set_resources(j('foo','bar','quux.txt'), j('foo','bar','zap.txt'))
self._assert_resource_dir_was_created_as_child_of(self.chief.data)
self._assert_resource_dir_contains_resources()
def test_two_nested_resources_in_same_directory_get_same_parent(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('suite'))
self._set_resources(j('suite','foo','bar','quux.txt'), j('suite','foo','bar','zap.txt'))
assert_equals(self.chief.data.children[0].children[0].children,
self.chief.resources)
def test_resource_directory_gets_nearest_possible_parent(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('tmp'))
self.chief.data.add_child(TestDataDirectoryController(self._data_directory(j('tmp','some'))))
self._set_resources(j('tmp','some','resoruces','res.txt'))
assert_equals(len(self.chief.data.children), 1)
assert_equals(len(self.chief.data.children[0].children), 1)
assert_equals(self.chief.data.children[0].children[0].children, [self.chief.resources[0]])
def test_nested_resource_directories(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('tmp'))
self._set_resources(j('tmp','resoruces','res.txt'), j('tmp','resoruces','more','res.txt'))
assert_equals(len(self.chief.data.children), 1)
assert_equals(len(self.chief.data.children[0].children), 2)
assert_equals(self.chief.data.children[0].children[1].children, [self.chief.resources[1]])
def test_resource_in_nested_directory(self):
self.chief._controller = TestDataDirectoryController(self._data_directory('tmp'))
self._set_resources(j('tmp','res','ources','res.txt'))
assert_equals(len(self.chief.data.children), 1)
assert_equals(len(self.chief.data.children[0].children), 1)
assert_equals(self.chief.data.children[0].children[0].children, [self.chief.resources[0]])
assert_true(len(self.chief.external_resources)== 0)
def _data_directory(self, path):
data = TestDataDirectory()
data.source = data.directory = os.path.normpath(path)
return data
def _set_resources(self, *paths):
for p in paths:
resource = ResourceFileController(ResourceFile(os.path.normpath(p)))
self.chief.resources.append(resource)
self.chief._insert_into_suite_structure(resource)
def _assert_resource_dir_was_created_as_child_of(self, ctrl):
assert_equals(len(ctrl.children), 1)
def _assert_resource_dir_contains_resources(self):
assert_equals(self.chief.data.children[0].children, self.chief.resources)
示例15: test_deleting_file_suite_under_dir_suite
def test_deleting_file_suite_under_dir_suite(self):
chief = ChiefController(Namespace())
chief._controller = TestDataDirectoryController(TestDataDirectory(source=self._dirpath).populate(), chief)
file_suite = chief.data.children[0]
file_suite.remove()
assert_true(len(chief.data.children) == 0, 'Child suite was not removed')