Exemplo n.º 1
0
 def test_nothing_done(self):
     with LogCapture() as capture:
         nothing_done(self.log_printer)
     capture.check(
         ('root', 'WARNING', 'No existent section was targeted or enabled. '
                             'Nothing to do.')
     )
 def test_nothing_done(self):
     with LogCapture() as capture:
         nothing_done(self.log_printer)
     capture.check(
         ('root', 'WARNING', 'No existent section was targeted or enabled. '
                             'Nothing to do.')
     )
Exemplo n.º 3
0
    def test_static_functions(self):
        with retrieve_stdout() as stdout:
            print_section_beginning(self.console_printer, Section("name"))
            self.assertEqual(stdout.getvalue(),
                             _("Executing section "
                               "{name}...").format(name="name") + "\n")

        with retrieve_stdout() as stdout:
            nothing_done(self.console_printer)
            self.assertEqual(stdout.getvalue(),
                             _("No existent section was targeted or enabled. "
                               "Nothing to do.") + "\n")
Exemplo n.º 4
0
def main():
    log_printer = LogPrinter(ConsolePrinter())
    console_printer = ConsolePrinter()
    exitcode = 0
    try:
        did_nothing = True
        yielded_results = False
        (sections,
         local_bears,
         global_bears,
         targets) = gather_configuration(acquire_settings, log_printer)

        if bool(sections["default"].get("show_bears", "False")):
            show_bears(local_bears,
                       global_bears,
                       console_printer)
            did_nothing = False
        else:
            for section_name in sections:
                section = sections[section_name]
                if not section.is_enabled(targets):
                    continue

                file_diff_dict = {}
                print_section_beginning(console_printer, section)
                results = execute_section(
                    section=section,
                    global_bear_list=global_bears[section_name],
                    local_bear_list=local_bears[section_name],
                    print_results=print_results,
                    log_printer=log_printer,
                    file_diff_dict=file_diff_dict)
                yielded_results = yielded_results or results[0]
                finalize(file_diff_dict, results[3], log_printer)
                did_nothing = False

        if did_nothing:
            nothing_done(console_printer)

        if yielded_results:
            exitcode = 1
    except BaseException as exception:  # pylint: disable=broad-except
        exitcode = exitcode or get_exitcode(exception, log_printer)

    return exitcode
Exemplo n.º 5
0
 def test_nothing_done(self):
     with retrieve_stdout() as stdout:
         nothing_done(self.log_printer)
         self.assertIn(
             "No existent section was targeted or enabled. "
             "Nothing to do.\n", stdout.getvalue())
Exemplo n.º 6
0
 def test_nothing_done(self):
     nothing_done(self.log_printer)
     self.assertEqual(['No existent section was targeted or enabled. '
                       'Nothing to do.'],
                      [log.message for log in self.log_printer.logs])
Exemplo n.º 7
0
 def test_nothing_done(self):
     with retrieve_stdout() as stdout:
         nothing_done(self.log_printer)
         self.assertIn("No existent section was targeted or enabled. "
                       "Nothing to do.\n",
                       stdout.getvalue())
Exemplo n.º 8
0
 def test_nothing_done(self):
     with retrieve_stdout() as stdout:
         nothing_done(self.console_printer)
         self.assertEqual(stdout.getvalue(),
                          _("No existent section was targeted or enabled. "
                            "Nothing to do.") + "\n")