Page MenuHomePhabricator

Cannot run tests vs sites where oauth is configured in user-config.py
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • configure to use oauth for the site used for tests (e.g. en.wikisource in this case)
  • python -m unittest tests.proofreadpage_tests.TestProofreadPageValidSite.test_url_image

What happens?:

setUpClass (tests.proofreadpage_tests.TestProofreadPageValidSite) ... skipped 'TestProofreadPageValidSite: hostname https://en.wikisource.org/w/index.php failed: HTTP status: 400 - Bad Request'

What should have happened instead?:
the test should proceed

Reason is that /index.php does not accept requests with oauth.

In [9]: requests.get('https://en.wikisource.org/w/api.php', auth=oauth)
Out[9]: <Response [200]>

In [10]: requests.get('https://en.wikisource.org/w/index.php', auth=oauth)
Out[10]: <Response [400]>

hostname = data['hostname'] in setUpClass() of class CheckHostnameMixin(TestCaseBase) is set to ./index.php

data['hostname'] is defined in setUpClass() of class TestCase(TestCaseBase, metaclass=MetaTestCaseClass):

if 'hostname' not in data and 'site' in data:
    # Ignore if the family has defined this as
    # obsolete without a mapping to a hostname.
    with suppress(KeyError):
        data['hostname'] = (
            data['site'].base_url(data['site'].path()))

where data['site'].path() is the path() method of Family().

Event Timeline

I think that here we could use apipath, as the goal should be only to check that the site is online.

if 'hostname' not in data and 'site' in data:
    # Ignore if the family has defined this as
    # obsolete without a mapping to a hostname.
    with suppress(KeyError):
        data['hostname'] = (
            data['site'].base_url(data['site'].path()))  -->  data['site'].apipath()

But I am not familiar with all implications of aspects.py

Xqt triaged this task as High priority.Dec 15 2023, 9:18 AM