Page MenuHomePhabricator

Create some tests for pywikibot.diff.PatchManager
Closed, ResolvedPublic

Description

The function pywikibot.showDiff is an important part of the pywikibot UI, allowing users to quickly review proposed changes to be made. It uses color to maximise the amount of information that can be shown to the user on a text interface to help them make their decision.
The logic behind this function was migrated to pywikibot.diff.PatchManager and radically improved , and the switch to using PatchManager occurred in ce6e10ba.

However the module pywikibot.diff only has tests in diff_tests for T134341 (3c8c5eae24a14)

Some very basic tests should be created. There are a lot of interesting test scenarios on https://test.wikipedia.org/wiki/User:John_Vandenberg/diff_test (see T130572 for how to use it)

See documentation in tests/README.rst.

Then it is easier to add new tests when bugs are being fixed (e.g. T130572) and enhancements are added.

This should be an good first task task for a newbie.

Event Timeline

jayvdb renamed this task from pywikibot.diff has not tests to pywikibot.diff.PatchManager has no tests.May 16 2016, 1:52 AM
jayvdb updated the task description. (Show Details)
Xqt triaged this task as Lowest priority.Aug 27 2016, 4:54 PM
Aklapper renamed this task from pywikibot.diff.PatchManager has no tests to Create some tests for pywikibot.diff.PatchManager.Nov 27 2016, 10:24 PM

Change 324724 had a related patch set uploaded (by Sn1per):
Basic PatchManager unit tests

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

I was a little confused as to how to implement tests for the following from the diff_tests page:

{{}}Pywikipediabot{{{}}}
?
?{}Pywikipediabot?
+{yellow}Pywikipediabot
-{black}Pywikipediabot

Pywikipediabot{color}Pywikipediabot

{color}Pywikipediabot
{red}Pywikipediabot{red}

\03  foo Pywikibot    foo

%(foo)sPywikipediabot%(bar)s

You've looked through T130572?
Just do the ones you can, and supplement the tests with other types of interesting cases you can see will be helpful, even basic ones.

Change 324724 merged by jenkins-bot:
Basic PatchManager unit tests

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

Note we currently have good coverage, but there are still some major component of the PatchManager which do not have any coverage at all.
See https://codecov.io/gh/wikimedia/pywikibot-core/src/ca11a4c4ceb6e7ae3363d97c99b4d46b1ede50a6/pywikibot/diff.py

Note I am leaving this task closed, but I have added instances to the GCI task to improve the coverage. Keep using this phab task as the gerrit task. Maybe we get to 100% before the end of GCI (but this task gets harder each time someone adds more tests).

Change 331576 had a related patch set uploaded (by Phantom42):
Added tests for cherry_pick function of diff module

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

Change 331576 merged by jenkins-bot:
Added tests for cherry_pick function of diff module

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