def test_messagesLogged(self):
        self.env['INPUT_EXCLUDE_URL_PREFIX'] = \
            'https://www.google.com'
        with \
                patch.dict(os.environ, self.env),\
                patch.object(self.logger, 'error') as error_mock,\
                patch.object(self.logger, 'info') as info_mock:
            run_action()
            expected_errors = [
                f'::error ::ClientResponseError: 500 - {self.url}/page4.html',
                f'::error ::ClientResponseError: 404 - {self.url}/page3.html'
            ]
            actual_errors: List[str] = []
            for call in error_mock.call_args_list:
                args, kwargs = call
                actual_errors.append(args[0])
            self.assertEqual(expected_errors, actual_errors)

            expected_info_prefixes = [
                f'200 - {self.url} - ', f'200 - {self.url}/favicon.ico - ',
                f'200 - {self.url}/page1.html - ',
                f'200 - {self.url}/subpages/subpage1.html - ',
                f'200 - {self.url}/page2.html - ',
                f'200 - {self.url}/subpages/subpage2.html - ',
                f'200 - {self.url}/index.html - '
            ]
            actual_infos: List[str] = []
            for call in info_mock.call_args_list:
                args, kwargs = call
                actual_infos.append(args[0])
            self.assertEqual(len(expected_info_prefixes), len(actual_infos))
            for expected_prefix in expected_info_prefixes:
                found = False
                for actual in actual_infos:
                    if (actual.startswith(expected_prefix)):
                        actual_infos.remove(actual)
                        found = True
                        break
                self.assertTrue(
                    found, 'Did not find actual result beginning' +
                    ' with "{expected_prefix}"')
            self.assertFalse(actual_infos,
                             f'Unexpected actual responses: {actual_infos}')
 def test_config_values(self):
     run_action()
     self.deadseeker.assert_called_once()
     config: SeekerConfig = self.deadseeker.call_args.args[0]
     self.assertEqual(config.search_attrs, TEST_SEARCH_ATTRS)
     self.assertEqual(config.max_tries, TEST_MAX_TRIES)
     self.assertEqual(config.max_time, TEST_MAX_TIME)
     self.assertEqual(config.max_depth, TEST_MAX_DEPTH)
     self.assertEqual(config.includeprefix, TEST_INCLUDE_PREFIX)
     self.assertEqual(config.excludeprefix, TEST_EXCLUDE_PREFIX)
     self.assertEqual(config.includesuffix, TEST_INCLUDE_SUFFIX)
     self.assertEqual(config.excludesuffix, TEST_EXCLUDE_SUFFIX)
     self.assertEqual(config.includecontained, TEST_INCLUDE_CONTAINED)
     self.assertEqual(config.excludecontained, TEST_EXCLUDE_CONTAINED)
     self.assertEqual(config.alwaysgetonsite, TEST_ALWAYS_GET_ONSITE)
     self.assertEqual(config.resolvebeforefilter,
                      TEST_RESOLVE_BEFORE_FILTERING)
     self.assertEqual(config.connect_limit_per_host,
                      TEST_CONNECT_LIMIT_PER_HOST)
     self.assertEqual(config.timeout, TEST_TIMEOUT)
 def test_exit_1_on_any_failure(self):
     self.env['INPUT_EXCLUDE_URL_PREFIX'] = \
         'https://www.google.com'
     with patch.dict(os.environ, self.env):
         run_action()
     self.exit.assert_called_with(1)
 def test_works(self):
     self.env['INPUT_EXCLUDE_URL_PREFIX'] = \
         'https://www.google.com,/page3.html,/page4.html'
     with patch.dict(os.environ, self.env):
         run_action()
     self.exit.assert_not_called()
 def test_verboseTrueSetsLoggingToDebug(self):
     self.inputvalidator.get_verbosity.return_value = True
     with patch.object(logging, 'basicConfig') as mock_debug:
         run_action()
         mock_debug.assert_called_once_with(level=logging.INFO,
                                            format='%(message)s')
 def test_log_critical_when_failed(self):
     self.seekresults.failures.append(MagicMock())
     self.seek.return_value = self.seekresults
     run_action()
     self.critical.assert_called_with('::error ::Found some broken links!')
 def test_testActionExitWhenFailed(self):
     self.seekresults.failures.append(MagicMock())
     self.seek.return_value = self.seekresults
     run_action()
     self.seek.assert_called_with(TEST_URLS, self.loggingresponsehandler())
     self.exit.assert_called_with(1)
 def test_no_log_critical_when_no_failed(self):
     self.seek.return_value = self.seekresults
     run_action()
     self.critical.assert_not_called()
 def test_no_exit_when_no_failed(self):
     self.seek.return_value = self.seekresults
     run_action()
     self.seek.assert_called_with(TEST_URLS, self.loggingresponsehandler())
     self.exit.assert_not_called()
 def test_verboseLogLevelSetsLoggingToSevere(self):
     for level in [DEBUG, INFO, WARN, ERROR, CRITICAL]:
         self.inputvalidator.get_verbosity.return_value = level
         with patch.object(logging, 'basicConfig') as mock_debug:
             run_action()
             mock_debug.assert_called_once_with(level=level)