HomePhabricator

Mock has_geolocation in test_processSource_with_one_okay_picture_out_of_two

Authored by JeanFred on Jul 26 2018, 10:10 AM.

Description

Mock has_geolocation in test_processSource_with_one_okay_picture_out_of_two

Trying to run the unit tests offline resulted in the following error:

ERROR: Traceback (most recent call last):
  File "pywikibot/data/api.py", line 1954, in submit
    body=body, headers=headers)
  File "pywikibot/tools/__init__.py", line 1448, in wrapper
    return obj(*__args, **__kw)
  File "pywikibot/comms/http.py", line 328, in request
    r = fetch(baseuri, method, params, body, headers, **kwargs)
  File "pywikibot/comms/http.py", line 515, in fetch
    error_handling_callback(request)
  File "pywikibot/comms/http.py", line 402, in error_handling_callback
    raise request.data
ConnectionError: HTTPSConnectionPool(host='commons.wikimedia.org', port=443):
Max retries exceeded with url: /w/api.php
Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection>:
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

This is because test_processSource_with_one_okay_picture_out_of_two hits
the has_geolocation method, which queries the Wikimedia Commons API.

As such that call needs to be mocked, like we already do for the others
methods in TestProcessSource

Bug: T200410
Change-Id: I260a74d0f9e00cf3302c12b550eb573ef1c1f48d