JJMC89 created this task.
JJMC89 added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
18:43:44 ______________ TestCommonsQueryService.testLoginAndOauthPermisson
______________
18:43:44
18:43:44 self = <tests.sparql_tests.TestCommonsQueryService
testMethod=testLoginAndOauthPermisson>
18:43:44
18:43:44 def testLoginAndOauthPermisson(self):
18:43:44 """Commons Query Service Login and Oauth permission."""
18:43:44 # Define the SPARQL query
18:43:44 query = 'SELECT ?a ?b WHERE { ?a wdt:P9478 ?b } LIMIT 4'
18:43:44
18:43:44 # Set up the SPARQL endpoint and entity URL
18:43:44 # Note: https://commons-query.wikimedia.org
18:43:44 # requires user to be logged in
18:43:44
18:43:44 entity_url = 'https://commons.wikimedia.org/entity/'
18:43:44 endpoint = 'https://commons-query.wikimedia.org/sparql'
18:43:44
18:43:44 # Create a SparqlQuery object
18:43:44 query_object = sparql.SparqlQuery(endpoint=endpoint,
18:43:44 entity_url=entity_url)
18:43:44
18:43:44 # Execute the SPARQL query and retrieve the data user not
logged in
18:43:44 with self.assertRaisesRegex(NoUsernameError, 'User not
logged in'):
18:43:44 > query_object.select(query, full_data=False)
18:43:44
18:43:44 tests/sparql_tests.py:210:
18:43:44 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:43:44 pywikibot/data/sparql.py:116: in select
18:43:44 data = self.query(query, headers=headers)
18:43:44 pywikibot/data/sparql.py:158: in query
18:43:44 self.last_response = http.fetch(url, headers=headers)
18:43:44 pywikibot/comms/http.py:457: in fetch
18:43:44 callback(response)
18:43:44 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:43:44
18:43:44 def error_handling_callback(response):
18:43:44 """
18:43:44 Raise exceptions and log alerts.
18:43:44
18:43:44 :param response: Response returned by Session.request().
18:43:44 :type response: :py:obj:`requests.Response`
18:43:44 """
18:43:44 # TODO: do some error correcting stuff
18:43:44 if isinstance(response, requests.exceptions.SSLError) \
18:43:44 and 'certificate verify failed' in str(response):
18:43:44 raise FatalServerError(str(response))
18:43:44
18:43:44 if isinstance(response, requests.ConnectionError):
18:43:44 msg = str(response)
18:43:44 if ('NewConnectionError' in msg or
'NameResolutionError' in msg) \
18:43:44 and re.search(r'\[Errno (-2|8|11001)\]', msg):
18:43:44 raise ConnectionError(response)
18:43:44
18:43:44 # catch requests.ReadTimeout and requests.ConnectTimeout
and convert
18:43:44 # it to ServerError
18:43:44 if isinstance(response, requests.Timeout):
18:43:44 raise ServerError(response)
18:43:44
18:43:44 if isinstance(response, ValueError):
18:43:44 # MissingSchema, InvalidSchema, InvalidURL,
InvalidHeader
18:43:44 raise FatalServerError(str(response))
18:43:44
18:43:44 if isinstance(response, Exception):
18:43:44 with suppress(Exception):
18:43:44 # request exception may contain response and
request attribute
18:43:44 error('An error occurred for uri ' +
response.request.url)
18:43:44 raise response from None
18:43:44
18:43:44 if response.status_code == HTTPStatus.REQUEST_URI_TOO_LONG:
18:43:44 raise
Client414Error(HTTPStatus(response.status_code).description)
18:43:44
18:43:44 if response.status_code == HTTPStatus.GATEWAY_TIMEOUT:
18:43:44 raise Server504Error(
18:43:44 f'Server {urlparse(response.url).netloc} timed
out')
18:43:44
18:43:44 if (not response.ok
18:43:44 and response.status_code >=
HTTPStatus.INTERNAL_SERVER_ERROR):
18:43:44 > raise ServerError(
18:43:44 f'{response.status_code} Server Error:
{response.reason}')
18:43:44 E pywikibot.exceptions.ServerError: 500 Server Error:
Internal Server Error
18:43:44
18:43:44 pywikibot/comms/http.py:353: ServerError
Source:
https://integration.wikimedia.org/ci/job/pywikibot-core-tox-deeptest-py312/138/console
TASK DETAIL
https://phabricator.wikimedia.org/T378788
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: JJMC89
Cc: Aklapper, pywikibot-bugs-list, JJMC89, mevo, PotsdamLamb, Jyoo1011,
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho,
MayS, Mdupont, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx, Xqt,
jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]