jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] site_tests: Use assertLessEqual
......................................................................
[IMPROV] site_tests: Use assertLessEqual
Instead of using assertTrue, which will only say that the result was False when
it doesn't apply, it's using now assertLessEqual which hopefully shows the
values compared. If both values are a set the two operations are the same:
a <= b and a.issubset(b)
Change-Id: I64a1a311a3a2a1c617279444442230b966bd5b31
---
M tests/site_tests.py
1 file changed, 6 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 70e2b15..ae56705 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -397,11 +397,12 @@
filterRedirects=False))
self.assertEqual(filtered & redirs, set([]))
self.assertEqual(indirect & redirs, set([]))
- self.assertTrue(filtered.issubset(indirect))
- self.assertTrue(filtered.issubset(backlinks))
- self.assertTrue(redirs.issubset(backlinks))
- self.assertTrue(backlinks.issubset(
- set(mysite.pagebacklinks(mainpage, namespaces=[0, 2]))))
+ self.assertLessEqual(filtered, indirect)
+ self.assertLessEqual(filtered, backlinks)
+ self.assertLessEqual(redirs, backlinks)
+ self.assertLessEqual(
+ backlinks,
+ set(self.site.pagebacklinks(mainpage, namespaces=[0, 2])))
# pagereferences includes both backlinks and embeddedin
embedded = set(mysite.page_embeddedin(mainpage, namespaces=[0]))
--
To view, visit https://gerrit.wikimedia.org/r/231326
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I64a1a311a3a2a1c617279444442230b966bd5b31
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] TestLink: Update assertEquals to assertEqual
......................................................................
[FIX] TestLink: Update assertEquals to assertEqual
In e5a24ab3 some tests were added which also used assertEquals which has been
deprecated and replaced by assertEqual.
Change-Id: I77a3f42f05c0aeffa8ba57c49f9f55d61ff0e0d9
---
M tests/link_tests.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/link_tests.py b/tests/link_tests.py
index 34cd32c..0b134c5 100644
--- a/tests/link_tests.py
+++ b/tests/link_tests.py
@@ -146,16 +146,16 @@
# Subpage
p = Page(self.get_site(), 'Foo')
l = Link('/bar', p)
- self.assertEquals(l.title, 'Foo/bar')
- self.assertEquals(l.site, self.get_site())
+ self.assertEqual(l.title, 'Foo/bar')
+ self.assertEqual(l.site, self.get_site())
# Subpage of Page with section
p = Page(self.get_site(), 'Foo#Baz')
l = Link('/bar', p)
- self.assertEquals(l.title, 'Foo/bar')
- self.assertEquals(l.site, self.get_site())
+ self.assertEqual(l.title, 'Foo/bar')
+ self.assertEqual(l.site, self.get_site())
# Non-subpage link text beginning with slash
l = Link('/bar', self.get_site())
- self.assertEquals(l.title, '/bar')
+ self.assertEqual(l.title, '/bar')
class Issue10254TestCase(DefaultDrySiteTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/231252
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I77a3f42f05c0aeffa8ba57c49f9f55d61ff0e0d9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove siteinfo key maxuploadsize from tests
......................................................................
Remove siteinfo key maxuploadsize from tests
It is only present on MediaWiki 1.20+
and is not used by pywikibot.
Bug: T108933
Change-Id: I85559e7089940376b1b5070d3e9a5a57dff58fc4
---
M tests/site_tests.py
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
VcamX: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 182cd7f..70e2b15 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1784,7 +1784,6 @@
self.assertIsInstance(
datetime.strptime(mysite.siteinfo['time'], '%Y-%m-%dT%H:%M:%SZ'),
datetime)
- self.assertGreater(mysite.siteinfo['maxuploadsize'], 0)
self.assertIn(mysite.siteinfo['case'], ["first-letter", "case-sensitive"])
self.assertEqual(mysite.case(), mysite.siteinfo['case'])
self.assertEqual(re.findall("\$1", mysite.siteinfo['articlepath']), ["$1"])
--
To view, visit https://gerrit.wikimedia.org/r/231203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I85559e7089940376b1b5070d3e9a5a57dff58fc4
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: VcamX <vcamx3(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Add force option to APISite.getuserinfo
......................................................................
[IMPROV] Add force option to APISite.getuserinfo
Change-Id: I6dd0563c373119c6723c833fd8285901d01682ba
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 11 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ccc11c6..81ea424 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1813,10 +1813,8 @@
return
# check whether a login cookie already exists for this user
self._loginstatus = LoginStatus.IN_PROGRESS
- if hasattr(self, "_userinfo"):
- del self._userinfo
try:
- self.getuserinfo()
+ self.getuserinfo(force=True)
if self.userinfo['name'] == self._username[sysop] and \
self.logged_in(sysop):
return
@@ -1826,9 +1824,7 @@
user=self._username[sysop])
if loginMan.login(retry=True):
self._username[sysop] = loginMan.username
- if hasattr(self, "_userinfo"):
- del self._userinfo
- self.getuserinfo()
+ self.getuserinfo(force=True)
self._loginstatus = (LoginStatus.AS_SYSOP
if sysop else LoginStatus.AS_USER)
else:
@@ -1846,11 +1842,9 @@
uirequest = self._simple_request(action='logout')
uirequest.submit()
self._loginstatus = LoginStatus.NOT_LOGGED_IN
- if hasattr(self, "_userinfo"):
- del self._userinfo
- self.getuserinfo()
+ self.getuserinfo(force=True)
- def getuserinfo(self):
+ def getuserinfo(self, force=False):
"""Retrieve userinfo from site and store in _userinfo attribute.
self._userinfo will be a dict with the following keys and values:
@@ -1863,8 +1857,10 @@
- message: present if user has a new message on talk page
- blockinfo: present if user is blocked (dict)
+ @param force: force to retrieve userinfo ignoring cache
+ @type force: bool
"""
- if (not hasattr(self, '_userinfo') or
+ if (not hasattr(self, '_userinfo') or force or
'rights' not in self._userinfo or
self._userinfo['name'] != self._username['sysop' in self._userinfo['groups']]):
uirequest = self._simple_request(
--
To view, visit https://gerrit.wikimedia.org/r/231210
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6dd0563c373119c6723c833fd8285901d01682ba
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: VcamX <vcamx3(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Create new topics on a Flow board
......................................................................
Create new topics on a Flow board
This patch adds functionality that allows bots to create new topics
on existing Flow boards.
Bug: T105129
Change-Id: I3b35082dde30f35df7663e265c89754c73f9ecb8
---
M pywikibot/flow.py
M pywikibot/site.py
M tests/flow_edit_tests.py
3 files changed, 81 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/flow.py b/pywikibot/flow.py
index 9c032b4..1580edb 100644
--- a/pywikibot/flow.py
+++ b/pywikibot/flow.py
@@ -138,6 +138,20 @@
cont_args = self._parse_url(data['links']['pagination'])
data = self.site.load_topiclist(self, **cont_args)
+ def new_topic(self, title, content, format='wikitext'):
+ """Create and return a Topic object for a new topic on this Board.
+
+ @param title: The title of the new topic (must be in plaintext)
+ @type title: unicode
+ @param content: The content of the topic's initial post
+ @type content: unicode
+ @param format: The content format of the value supplied for content
+ @type format: unicode (either 'wikitext' or 'html')
+ @return: The new topic
+ @rtype: Topic
+ """
+ return Topic.create_topic(self, title, content, format)
+
class Topic(FlowPage):
@@ -150,6 +164,24 @@
return self._data
@classmethod
+ def create_topic(cls, board, title, content, format='wikitext'):
+ """Create and return a Topic object for a new topic on a Board.
+
+ @param board: The topic's parent board
+ @type board: Board
+ @param title: The title of the new topic (must be in plaintext)
+ @type title: unicode
+ @param content: The content of the topic's initial post
+ @type content: unicode
+ @param format: The content format of the value supplied for content
+ @type format: unicode (either 'wikitext' or 'html')
+ @return: The new topic
+ @rtype: Topic
+ """
+ data = board.site.create_new_topic(board, title, content, format)
+ return cls(board.site, data['topic-page'])
+
+ @classmethod
def from_topiclist_data(cls, board, root_uuid, topiclist_data):
"""Create a Topic object from API data.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ccc11c6..70ed67b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5873,6 +5873,30 @@
@must_be('user')
@need_extension('Flow')
+ def create_new_topic(self, page, title, content, format):
+ """Create a new topic on a Flow board.
+
+ @param page: A Flow board
+ @type page: Board
+ @param title: The title of the new topic (must be in plaintext)
+ @type title: unicode
+ @param content: The content of the topic's initial post
+ @type content: unicode
+ @param format: The content format of the value supplied for content
+ @type format: unicode (either 'wikitext' or 'html')
+ @return: The metadata of the new topic
+ @rtype: dict
+ """
+ token = self.tokens['csrf']
+ params = {'action': 'flow', 'page': page, 'token': token,
+ 'submodule': 'new-topic', 'ntformat': format,
+ 'nttopic': title, 'ntcontent': content}
+ req = self._request(parameters=params, use_get=False)
+ data = req.submit()
+ return data['flow']['new-topic']['committed']['topiclist']
+
+ @must_be('user')
+ @need_extension('Flow')
def reply_to_post(self, page, reply_to_uuid, content, format):
"""Reply to a post on a Flow topic.
diff --git a/tests/flow_edit_tests.py b/tests/flow_edit_tests.py
index 863fb71..9844f5d 100644
--- a/tests/flow_edit_tests.py
+++ b/tests/flow_edit_tests.py
@@ -9,7 +9,7 @@
__version__ = '$Id$'
-from pywikibot.flow import Topic, Post
+from pywikibot.flow import Board, Topic, Post
from pywikibot.tools import PY2
from tests.aspects import TestCase
@@ -18,6 +18,30 @@
unicode = str
+class TestFlowCreateTopic(TestCase):
+
+ """Test the creation of Flow topics."""
+
+ family = 'test'
+ code = 'test'
+
+ user = True
+ write = True
+
+ def test_create_topic(self):
+ """Test creation of topic."""
+ site = self.get_site()
+ content = 'If you can read this, the Flow code in Pywikibot works!'
+ board = Board(site, 'Talk:Pywikibot test')
+ topic = board.new_topic('Pywikibot test', content, 'wikitext')
+ first_post = topic.replies()[0]
+ wikitext = first_post.get(format='wikitext')
+ self.assertIn('wikitext', first_post._content)
+ self.assertNotIn('html', first_post._content)
+ self.assertIsInstance(wikitext, unicode)
+ self.assertEqual(wikitext, content)
+
+
class TestFlowReply(TestCase):
"""Test replying to existing posts."""
--
To view, visit https://gerrit.wikimedia.org/r/223525
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3b35082dde30f35df7663e265c89754c73f9ecb8
Gerrit-PatchSet: 9
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Happy5214 <happy5214(a)gmail.com>
Gerrit-Reviewer: Happy5214 <happy5214(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Mattflaschen <mflaschen(a)wikimedia.org>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>