Пример #1
0
 def take_action(self, parsed_args):
     LOG.info('Starting url access check for {0}'.format(parsed_args.urls))
     try:
         api.check_urls(parsed_args.urls)
     except errors.UrlNotAvailable as e:
         sys.stdout.write(str(e))
         raise e
Пример #2
0
 def take_action(self, parsed_args):
     LOG.info('Starting url access check for {0}'.format(parsed_args.urls))
     try:
         api.check_urls(parsed_args.urls)
     except errors.UrlNotAvailable as e:
         sys.stdout.write(str(e))
         raise e
Пример #3
0
 def take_action(self, parsed_args):
     LOG.info('Starting url access check for {0}'.format(parsed_args.urls))
     proxies = {}
     if parsed_args.http_proxy:
         proxies['http'] = parsed_args.http_proxy
     if parsed_args.https_proxy:
         proxies['https'] = parsed_args.https_proxy
     try:
         api.check_urls(parsed_args.urls,
                        proxies=proxies or None,
                        timeout=parsed_args.timeout)
     except errors.UrlNotAvailable as e:
         sys.stdout.write(str(e))
         raise e
Пример #4
0
    def test_check_urls(self, req_mocker):
        for url in self.urls:
            req_mocker.get(url, status_code=200)

        check_result = api.check_urls(self.urls)

        self.assertTrue(check_result)
Пример #5
0
 def test_check_ftp_fail(self):
     with self.assertRaises(errors.UrlNotAvailable):
         api.check_urls(self.paths)
Пример #6
0
 def test_check_ftp(self, _):
     check_result = api.check_urls(self.ftps, timeout=5)
     self.assertTrue(check_result)
Пример #7
0
 def test_check_paths_fail(self, mock_exists):
     mock_exists.return_value = False
     with self.assertRaises(errors.UrlNotAvailable):
         api.check_urls(self.paths)
Пример #8
0
    def test_check_paths(self, mock_exists):
        mock_exists.return_value = True
        check_result = api.check_urls(self.paths)

        self.assertTrue(check_result)
Пример #9
0
    def test_check_urls_fail(self, req_mocker):
        for url in self.urls:
            req_mocker.get(url, status_code=404)

        with self.assertRaises(errors.UrlNotAvailable):
            api.check_urls(self.urls)
Пример #10
0
 def check_url(self, url, http_proxy):
     try:
         return urlck.check_urls([url], proxies={'http': http_proxy})
     except url_errors.UrlNotAvailable:
         return False
Пример #11
0
 def check_url(self, url, http_proxy):
     try:
         return urlck.check_urls([url], proxies={'http': http_proxy})
     except url_errors.UrlNotAvailable:
         return False