def test_load_exception(self):
        """ Reporter.load() exception test """

        undefined = 'undefined'
        with self.assertRaises(ReporterError) as context:
            Reporter.load(undefined,'test.local', {})
            self.assertTrue('Unable to get reporter `{plugin}`'.format(plugin=undefined) in context.exception)
            self.assertTrue(ReporterError == context.expected)
示例#2
0
    def test_load_exception(self):
        """ Reporter.load() exception test """

        undefined = 'undefined'
        with self.assertRaises(ReporterError) as context:
            Reporter.load(undefined,'test.local', {})
            self.assertTrue('Unable to get reporter `{plugin}`'.format(plugin=undefined) in context.exception)
            self.assertTrue(ReporterError == context.expected)
示例#3
0
    def test_load_plugin_exception(self, ext):
        """ Reporter.load() exception test """

        if ext in ['html', 'json', 'txt']:

            PluginProvider.CONFIG_FILE = 'wrong.cfg'
            with self.assertRaises(Exception) as context:
                Reporter.load(ext, 'test.local', self.mockdata)
                self.assertTrue(Exception == context.expected)
示例#4
0
    def test_process(self, ext):
        """ Reporter.load().process() test """

        report = Reporter.load(ext, 'test.local', self.mockdata)
        self.assertIsNone(report.process())
        if ext in ['html','json']:
            self.assertTrue(filesystem.is_exist('tests/reports/test.local', 'test.local.{0}'.format(ext)))
        if ext in ['txt']:
            self.assertTrue(filesystem.is_exist('tests/reports/test.local', 'success.{0}'.format(ext)))
        shutil.rmtree('tests/reports')
示例#5
0
    def done(self):
        """
        Scan finish action
        :raise BrowserError
        :return: None
        """

        self.__result['total'].update({"items": self.__pool.total_items_size})
        self.__result['total'].update({"workers": self.__pool.workers_size})

        if 0 == self.__pool.size:

            try:
                for rtype in self.__config.reports:
                    report = Reporter.load(rtype, self.__config.host, self.__result)
                    report.process()
            except ReporterError as error:
                raise BrowserError(error)
        else:
            pass
示例#6
0
    def done(self):
        """
        Scan finish action
        :raise BrowserError
        :return: None
        """

        self.__result['total'].update({"items": self.__pool.total_items_size})
        self.__result['total'].update({"workers": self.__pool.workers_size})

        if 0 == self.__pool.size:

            try:
                for rtype in self.__config.reports:
                    report = Reporter.load(rtype, self.__config.host, self.__result)
                    report.process()
            except ReporterError as error:
                raise BrowserError(error)
        else:
            pass
    def test_is_reported(self):
        """ Reporter.is_reported() test """

        expected = Reporter.is_reported('resource')
        self.assertIs(type(expected), bool)
    def test_load(self, value):
        """ Reporter.load() test """

        expected = Reporter.load(value, 'test.local', {})
        self.assertIsInstance(expected, PluginProvider)
示例#9
0
    def test_is_reported(self):
        """ Reporter.is_reported() test """

        expected = Reporter.is_reported('resource')
        self.assertIs(type(expected), bool)
示例#10
0
    def test_load(self, value):
        """ Reporter.load() test """

        expected = Reporter.load(value, 'test.local', {})
        self.assertIsInstance(expected, PluginProvider)