jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] tests: add support for hostname check ......................................................................
[IMPROV] tests: add support for hostname check
If no sites are needed but only hostname must be checked it is now possible to either define one hostname or multiple hostnames and it'll automatically creates sites from it.
There are already two instances which used a hostname without a site parameter, which wasn't recognized. And thus they need the net=True explicitly defined.
Change-Id: I4f956c6db6fc4adf62973873759500ec88533423 --- M tests/api_tests.py M tests/aspects.py M tests/http_tests.py 3 files changed, 18 insertions(+), 5 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/api_tests.py b/tests/api_tests.py index 6119baf..213cf3b 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -835,7 +835,6 @@ it impossible to test two scenarios with the same APISite object. """
- net = True hostname = 'steward.wikimedia.org'
@classmethod diff --git a/tests/aspects.py b/tests/aspects.py index 5710e8d..f4016d7 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -685,12 +685,21 @@ # Inherit superclass attributes for base in bases: for key in ('pwb', 'net', 'site', 'user', 'sysop', 'write', - 'sites', 'family', 'code', 'dry', - 'cached', 'cacheinfo', 'wikibase'): + 'sites', 'family', 'code', 'dry', 'hostname', + 'hostnames', 'cached', 'cacheinfo', 'wikibase'): if hasattr(base, key) and key not in dct: # print('%s has %s; copying to %s' # % (base.__name__, key, name)) dct[key] = getattr(base, key) + + # Will be inserted into dct[sites] later + if 'hostname' in dct: + hostnames = [dct['hostname']] + del dct['hostname'] + elif 'hostnames' in dct: + hostnames = dct['hostnames'] + else: + hostnames = []
if 'net' in dct and dct['net'] is False: dct['site'] = False @@ -713,6 +722,13 @@ } }
+ if hostnames: + if 'sites' not in dct: + dct['sites'] = {} + for hostname in hostnames: + assert hostname not in dct['sites'] + dct['sites'][hostname] = {'hostname': hostname} + if 'dry' in dct and dct['dry'] is True: dct['net'] = False
diff --git a/tests/http_tests.py b/tests/http_tests.py index 8804345..cf8e4b4 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -344,8 +344,6 @@
"""Get binary file using requests and pywikibot."""
- net = True - hostname = 'upload.wikimedia.org' url = 'https://upload.wikimedia.org/wikipedia/commons/f/fc/MP_sounds.png'