Page MenuHomePhabricator

pywikibot.Site.protect does not have unit tests
Closed, ResolvedPublic

Description

There is no protect functionality in core yet!

valhallasw@lisilwen:~/src/pwb/pywikibot-core$ python pwb.py protect -links:User:Valhallasw/linkpage -site:test -family:test
Processing page User:Valhallasw
Do you want to change the protection level of [[test:User:Valhallasw]]? ([Y]es, [N]o, [A]ll) Y
Traceback (most recent call last):

File "pwb.py", line 123, in <module>
  run_python_file(fn, argv, argvu)
File "pwb.py", line 64, in run_python_file
  exec compile(source, filename, "exec") in main_mod.__dict__
File "scripts/protect.py", line 286, in <module>
  main()
File "scripts/protect.py", line 280, in main
  bot.run()
File "scripts/protect.py", line 137, in run
  move=self.move)
File "/home/valhallasw/src/pwb/pywikibot-core/pywikibot/__init__.py", line 251, in wrapper
  return method(*__args, **__kw)
File "/home/valhallasw/src/pwb/pywikibot-core/pywikibot/page.py", line 1417, in protect
  return self.site.protect(self, edit, move, reason)
File "/home/valhallasw/src/pwb/pywikibot-core/pywikibot/site.py", line 230, in __getattr__
  % (self.__class__.__name__, attr))

AttributeError: APISite instance has no attribute 'protect'


Version: core-(2.0)
Severity: normal

Details

Reference
bz57602

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 2:20 AM
bzimport added a project: Pywikibot-tests.
bzimport set Reference to bz57602.
bzimport added a subscriber: Unknown Object (????).

This has been implemented by GEOFBOT, but we should add some unit tests. Actual live testing would depend on a real test wiki, though...

(In reply to Merlijn van Deen from comment #1)

This has been implemented by GEOFBOT, but we should add some unit tests.
Actual live testing would depend on a real test wiki, though...

Why isnt test.wikipedia good enough?
Another option is WMF beta labs...?

The unit test framework has the ability to flag tests as 'write' tests, so they are not run by default.

Unicodesnowman set Security to None.
Unicodesnowman removed a subscriber: Unknown Object (????).
jayvdb added a subscriber: Aklapper.

@Aklapper, we need to grant protect rights to the Google-Code-in-2014 participant who claims this task. Is test.wikipedia.org the best place to do this testing?

jayvdb moved this task from Backlog to pywikibot on the Google-Code-in-2014 board.Dec 15 2014, 2:15 AM

Until you have protect rights on a wiki, you can use simulation mode to begin writing the tests.
In your user-config.py, add 'simulate = True'. See pywikibot/config2.py for more information about simulation mode.

Change 179878 had a related patch set uploaded (by Unicodesnowman):
Add unit tests for Site.protect() and Page.protect()

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

Patch-For-Review

Change 179878 merged by jenkins-bot:
Add tests for Site.protect(), Page.protect(), fix page locks

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

jayvdb closed this task as Resolved.Dec 16 2014, 9:40 AM