jenkins-bot has submitted this change and it was merged.

Change subject: Add edit failure tests for url data type
......................................................................


Add edit failure tests for url data type

Adds two tests for the url data type and makes the WbMonolingualText
tests more explicit.

Change-Id: Ib857db4ac926a199913cc4b596e14603c58c09da
---
M tests/edit_failure_tests.py
1 file changed, 25 insertions(+), 2 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index 811f303..1ddaf6e 100644
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -142,14 +142,18 @@
         item = pywikibot.ItemPage(repo, 'Q68')
         claim = self._make_WbMonolingualText_claim(repo, text='Test this!',
                                                    language='foo')
-        self.assertAPIError('modification-failed', None, item.addClaim, claim)
+        self.assertAPIError('modification-failed', 'Illegal value: foo',
+                            item.addClaim, claim)
 
     def test_WbMonolingualText_invalid_text(self):
         """Attempt adding a monolingual text with an invalid non-string 
text."""
         repo = self.get_repo()
         item = pywikibot.ItemPage(repo, 'Q68')
         claim = self._make_WbMonolingualText_claim(repo, text=123456, 
language='en')
-        self.assertAPIError('invalid-snak', None, item.addClaim, claim)
+        self.assertAPIError('invalid-snak',
+                            'Invalid snak (Can only construct a '
+                            'MonolingualTextValue with a string value.)',
+                            item.addClaim, claim)
 
     def test_math_invalid_function(self):
         """Attempt adding invalid latex to a math claim."""
@@ -159,6 +163,25 @@
         claim.setTarget('\foo')
         self.assertAPIError('modification-failed', None, item.addClaim, claim)
 
+    def test_url_malformed_url(self):
+        """Attempt adding a malformed URL to a url claim."""
+        repo = self.get_repo()
+        item = pywikibot.ItemPage(repo, 'Q68')
+        claim = pywikibot.page.Claim(repo, 'P506', datatype='url')
+        claim.setTarget('Not a URL at all')
+        self.assertAPIError('modification-failed',
+                            'Malformed URL: Not a URL at all',
+                            item.addClaim, claim)
+
+    def test_url_invalid_protocol(self):
+        """Attempt adding invalid latex to a math claim."""
+        repo = self.get_repo()
+        item = pywikibot.ItemPage(repo, 'Q68')
+        claim = pywikibot.page.Claim(repo, 'P506', datatype='url')
+        claim.setTarget('wtf://wikiba.se')
+        self.assertAPIError('modification-failed',
+                            'Unsupported URL scheme: wtf',
+                            item.addClaim, claim)
 
 if __name__ == '__main__':
     try:

-- 
To view, visit https://gerrit.wikimedia.org/r/268408
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib857db4ac926a199913cc4b596e14603c58c09da
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to