示例#1
0
    def setUp(self):
        super(TestSiteBlock, self).setUp()
        self.setup_dir()

        self.task = MockTask(base_dir=self.test_dir, make_task_dir=True)
        self.plugin = plugins.SiteBlock()

        self.mock_run_root(self.plugin)
        self.plugin.hosts_file = os.path.join(self.task.task_dir,
                                              'focus_test_hosts')
        open(self.plugin.hosts_file, 'w').write(_HOST_FILE_DATA)
        self.backup_hosts_file = os.path.join(self.task.task_dir, '.hosts.bak')
示例#2
0
    def testCallNotifyFunc___notify(self):
        """ Notify._notify: calls function defined by notify_func.
            """

        test_task = MockTask()
        test_task.start('Test-Task')

        ret_items = []

        def _check_func(task, message):
            ret_items.append((task, message))

        self.plugin.notify_func = _check_func

        self.plugin._notify(test_task, 'message-here')
        for item in ret_items:
            self.assertEqual(
                item, ('Focus ({0})'.format(test_task.name), 'message-here'))
示例#3
0
    def test__run_event_hooks(self):
        """ registration.run_event_hooks: runs the task event methods for
            registered event plugins.
            """
        plugin = MockPlugin()

        # fake event registration for plugin
        for event in ('task_start', 'task_run', 'task_end'):
            registration._event_hooks[event] = [(plugin.name, lambda: plugin)]

            # run event hooks for plugin, check if it works
            registration.run_event_hooks(event, MockTask())

            if event == 'task_start':
                self.assertTrue(hasattr(plugin, 'test__task_started'))

            elif event == 'task_run':
                self.assertTrue(hasattr(plugin, 'test__task_ran'))
                self.assertEqual(plugin.test__task_ran, 1)

            elif event == 'task_end':
                self.assertTrue(hasattr(plugin, 'test__task_ended'))
示例#4
0
 def setUp(self):
     super(TestEnvironment, self).setUp()
     self.setup_dir()
     self.env = Environment(data_dir=self.test_dir,
                            io=MockIOStream(),
                            task=MockTask())
示例#5
0
 def setUp(self):
     super(TestAppRun, self).setUp()
     self.setup_dir()
     self.task = MockTask()
     self.plugin = plugins.AppRun()
示例#6
0
 def setUp(self):
     super(TestAppBlock, self).setUp()
     self.task = MockTask()
     self.plugin = plugins.AppBlock()
示例#7
0
 def setUp(self):
     super(TestAppClose, self).setUp()
     self.task = MockTask()
     self.plugin = plugins.AppClose()