Page MenuHomePhabricator

site_tests.TestAlldeletedrevisionsAsUser fails
Closed, ResolvedPublic

Description

Currently our test passes TestAlldeletedrevisionsAsUser. This is because our test account hasn't deleted revisions. Therefore our test should be skipped if the data length is 0.

It would also be a good idea to use a for loop (maybe with subtests) instead of all function which is not explain the failure. Replacing the second test with

##        self.assertTrue(all('revisions' in data
##                            and isinstance(data['revisions'], dict)
##                            for data in drev))
        for data in drev:
            self.assertIn('revisions', data)
            self.assertIsInstance(data['revisions'], dict)

and let total=1 the result is shown as:

C:\pwb\GIT\core>py -3.9 pwb.py -user:xqbot site_tests -v TestAlldeletedrevisionsAsUser.test_basic
tests: max_retries reduced from 15 to 1
test_basic (__main__.TestAlldeletedrevisionsAsUser)
Test the site.alldeletedrevisions() method. ... FAIL

======================================================================
FAIL: test_basic (__main__.TestAlldeletedrevisionsAsUser)
Test the site.alldeletedrevisions() method.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\site_tests.py", line 1623, in test_basic
    self.assertIsInstance(data['revisions'], dict)
AssertionError: [{'revid': 214089678, 'parentid': 214089629, 'minor': '', 'user': 'Xqbot', 'timestamp': '2021-07-21T20:03:29Z'}] is not an instance of <class 'dict'>

----------------------------------------------------------------------
Ran 1 test in 1.883s

FAILED (failures=1)

C:\pwb\GIT\core>

The data item here is

{'ns': 6,
 'pageid': 0,
 'revisions': [{'minor': '',
                'parentid': 214089629,
                'revid': 214089678,
                'timestamp': '2021-07-21T20:03:29Z',
                'user': 'Xqbot'}],
 'title': 'Datei:Grabstein Peter Degner 1.jpg'}

The third test also fails completely. Using

##        self.assertTrue(all('user' in rev
##                            and rev['user'] == mysite.user()
##                            for data in drev
##                            for rev in data))
        for data in drev:
            for rev in data:
                self.assertIn('user', rev)
                self.assertEqual(rev['user'], mysite.user())

gives the following result:

C:\pwb\GIT\core>py -3.9 pwb.py -user:xqbot site_tests -v TestAlldeletedrevisionsAsUser.test_basic
tests: max_retries reduced from 15 to 1
test_basic (__main__.TestAlldeletedrevisionsAsUser)
Test the site.alldeletedrevisions() method. ... 
FAIL

======================================================================
FAIL: test_basic (__main__.TestAlldeletedrevisionsAsUser)
Test the site.alldeletedrevisions() method.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\site_tests.py", line 1630, in test_basic
    self.assertIn('user', rev)
AssertionError: 'user' not found in 'pageid'

----------------------------------------------------------------------
Ran 1 test in 2.276s

FAILED (failures=1)

C:\pwb\GIT\core>

See also T287332

Event Timeline

Xqt triaged this task as High priority.Jul 26 2021, 4:01 PM

Change 707869 had a related patch set uploaded (by Damian; author: Damian):

[pywikibot/core@master] [bugfix] site_tests.TestAlldeletedrevisionsAsUser fails

https://gerrit.wikimedia.org/r/707869

JJMC89 reassigned this task from JJMC89 to atagar.

Change 707869 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] site_tests.TestAlldeletedrevisionsAsUser fails

https://gerrit.wikimedia.org/r/707869