def test_override_saved_measure(self):
        """ Test that overriding a measure does override evrything.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl,
                                                 self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        # Create a new measure without headers and checks and test that the old
        # values are not in the config file.
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        measure.save_measure(path)

        conf = ConfigObj(path)
        assert_equal(conf['checks'], '[]')
        assert_equal(conf['headers'], '[]')
Exemple #2
0
    def test_override_saved_measure(self):
        """ Test that overriding a measure does override evrything.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl, self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        # Create a new measure without headers and checks and test that the old
        # values are not in the config file.
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        measure.save_measure(path)

        conf = ConfigObj(path)
        assert_equal(conf['checks'], '[]')
        assert_equal(conf['headers'], '[]')
Exemple #3
0
    def test_collect_headers(self):
        """ Test header collection.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin)
        measure.root_task = RootTask()

        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        measure.collect_headers(self.workbench)

        assert_equal(measure.root_task.default_header,
                     'Test header\nTest header')
    def test_collect_headers(self):
        """ Test header collection.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin)
        measure.root_task = RootTask()

        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        measure.collect_headers(self.workbench)

        assert_equal(measure.root_task.default_header,
                     'Test header\nTest header')
    def test_save_load_measure1(self):
        """ Test saving a measure to a file and reloading it.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl,
                                                 self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        assert_true(os.path.isfile(path))

        # Load measure.
        loaded = Measure.load_measure(plugin, path)

        assert_equal(loaded.name, 'Test')
        assert_equal(loaded.root_task.default_path, self.test_dir)
        assert_equal(loaded.checks, dict(plugin.checks))
        assert_equal(loaded.headers, dict(plugin.headers))
        assert_in(u'monitor1', loaded.monitors)

        monitor = loaded.monitors[u'monitor1']
        assert_true(monitor.save_test)

        # Check that all values have been correctly updated.
        monitor = measure.monitors[u'monitor1']
        assert_equal(monitor.measure_name, measure.name)
        assert_equal(monitor.measure_status, measure.status)
        assert_equal(monitor.updated, {'root/default_path': 1})
        assert_equal(measure.collect_entries_to_observe(),
                     ['root/default_path'])

        # Check that the notifier is correctly observed.
        assert_true(measure.root_task.task_database.has_observers('notifier'))
Exemple #6
0
    def test_save_load_measure1(self):
        """ Test saving a measure to a file and reloading it.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl, self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        assert_true(os.path.isfile(path))

        # Load measure.
        loaded = Measure.load_measure(plugin, path)

        assert_equal(loaded.name, 'Test')
        assert_equal(loaded.root_task.default_path, self.test_dir)
        assert_equal(loaded.checks, dict(plugin.checks))
        assert_equal(loaded.headers, dict(plugin.headers))
        assert_in(u'monitor1', loaded.monitors)

        monitor = loaded.monitors[u'monitor1']
        assert_true(monitor.save_test)

        # Check that all values have been correctly updated.
        monitor = measure.monitors[u'monitor1']
        assert_equal(monitor.measure_name, measure.name)
        assert_equal(monitor.measure_status, measure.status)
        assert_equal(monitor.updated, {'root/default_path': 1})
        assert_equal(measure.collect_entries_to_observe(),
                     ['root/default_path'])

        # Check that the notifier is correctly observed.
        assert_true(measure.root_task.task_database.has_observers('notifier'))
    def test_save_load_measure2(self):
        """ Test saving a measure to a file and reloading it with absent tools.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl,
                                                 self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        assert_true(os.path.isfile(path))

        # Remove test_suite
        self.workbench.unregister(u'tests.suite')

        # Load measure.
        loaded = Measure.load_measure(plugin, path)

        assert_equal(loaded.name, 'Test')
        assert_equal(loaded.root_task.default_path, self.test_dir)
        assert_equal(loaded.checks, {})
        assert_equal(loaded.headers, {})
        assert_equal(loaded.monitors, {})

        self.workbench.register(TestSuiteManifest())
Exemple #8
0
    def test_save_load_measure2(self):
        """ Test saving a measure to a file and reloading it with absent tools.

        """
        plugin = self.workbench.get_plugin(u'hqc_meas.measure')
        measure = Measure(plugin=plugin, name='Test', status='Under test')
        measure.root_task = RootTask(default_path=self.test_dir)

        # Needed because of Atom returning a _DictProxy
        measure.checks = dict(plugin.checks)
        # Needed because of Atom returning a _DictProxy
        measure.headers = dict(plugin.headers)
        # Adding a monitor.
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl, self.workbench))
        measure.monitors[u'monitor1'].save_test = True

        path = os.path.join(self.test_dir, 'saved_measure.ini')
        # Save measure.
        measure.save_measure(path)

        assert_true(os.path.isfile(path))

        # Remove test_suite
        self.workbench.unregister(u'tests.suite')

        # Load measure.
        loaded = Measure.load_measure(plugin, path)

        assert_equal(loaded.name, 'Test')
        assert_equal(loaded.root_task.default_path, self.test_dir)
        assert_equal(loaded.checks, {})
        assert_equal(loaded.headers, {})
        assert_equal(loaded.monitors, {})

        self.workbench.register(TestSuiteManifest())