def test_registered_user(self):
     """Test registered user."""
     user = User(self.site, 'Xqt')
     with suppress_warnings('pywikibot.page.User.name', DeprecationWarning):
         self.assertEqual(user.name(), user.username)
     self.assertEqual(user.title(with_ns=False), user.username)
     self.assertTrue(user.isRegistered())
     self.assertFalse(user.isAnonymous())
     self.assertIsInstance(user.registration(), pywikibot.Timestamp)
     self.assertGreater(user.editCount(), 0)
     self.assertFalse(user.isBlocked())
     self.assertTrue(user.isEmailable())
     self.assertEqual(user.gender(), 'unknown')
     self.assertIn('userid', user.getprops())
     self.assertEqual(user.getprops()['userid'], 287832)
     self.assertEqual(user.pageid, 6927779)
     self.assertEqual(user.getUserPage(),
                      pywikibot.Page(self.site, 'Benutzer:Xqt'))
     self.assertEqual(user.getUserPage(subpage='pwb'),
                      pywikibot.Page(self.site, 'Benutzer:Xqt/pwb'))
     self.assertEqual(user.getUserTalkPage(),
                      pywikibot.Page(self.site, 'Benutzer Diskussion:Xqt'))
     self.assertEqual(
         user.getUserTalkPage(subpage='pwb'),
         pywikibot.Page(self.site, 'Benutzer Diskussion:Xqt/pwb'))
     self.assertTrue(user.is_thankable)
     contribs = user.contributions(total=10)
     self.assertLength(list(contribs), 10)
     self.assertTrue(all(
         isinstance(contrib, tuple) for contrib in contribs))
     self.assertTrue(
         all('user' in contrib and contrib['user'] == user.username
             for contrib in contribs))
     self.assertIn('user', user.groups())
     self.assertIn('edit', user.rights())
Esempio n. 2
0
 def test_registered_user(self):
     """Test registered user."""
     user = User(self.site, 'Xqt')
     with suppress_warnings('pywikibot.page.User.name', DeprecationWarning):
         self.assertEqual(user.name(), user.username)
     self.assertEqual(user.title(withNamespace=False), user.username)
     self.assertTrue(user.isRegistered())
     self.assertFalse(user.isAnonymous())
     self.assertIsInstance(user.registration(), pywikibot.Timestamp)
     self.assertGreater(user.editCount(), 0)
     self.assertFalse(user.isBlocked())
     self.assertTrue(user.isEmailable())
     self.assertEqual(user.gender(), 'unknown')
     self.assertIn('userid', user.getprops())
     self.assertEqual(user.getprops()['userid'], 287832)
     self.assertEqual(user.pageid, 6927779)
     self.assertEqual(user.getUserPage(),
                      pywikibot.Page(self.site, 'Benutzer:Xqt'))
     self.assertEqual(user.getUserPage(subpage='pwb'),
                      pywikibot.Page(self.site, 'Benutzer:Xqt/pwb'))
     self.assertEqual(user.getUserTalkPage(),
                      pywikibot.Page(self.site, 'Benutzer Diskussion:Xqt'))
     self.assertEqual(user.getUserTalkPage(subpage='pwb'),
                      pywikibot.Page(self.site,
                                     'Benutzer Diskussion:Xqt/pwb'))
     self.assertTrue(user.is_thankable)
     contribs = user.contributions(total=10)
     self.assertEqual(len(list(contribs)), 10)
     self.assertTrue(all(isinstance(contrib, tuple)
                         for contrib in contribs))
     self.assertTrue(all('user' in contrib
                         and contrib['user'] == user.username
                         for contrib in contribs))
     self.assertIn('user', user.groups())
     self.assertIn('edit', user.rights())
Esempio n. 3
0
 def test_autoblocked_user_with_namespace(self):
     """Test autoblocked user."""
     # Suppress output: This is an autoblock ID, you can only use to unblock
     with patch.object(pywikibot, 'output'):
         user = User(self.site, 'User:#1242976')
     self.assertEqual('#1242976', user.username)
     self.assertEqual(user.title(with_ns=False), user.username[1:])
     self.assertFalse(user.isRegistered())
     self.assertFalse(user.isAnonymous())
     self.assertIsNone(user.registration())
     self.assertFalse(user.isEmailable())
     self.assertIn('invalid', user.getprops())
     self.assertTrue(user._isAutoblock)
     with self.assertRaisesRegex(AutoblockUserError,
                                 'This is an autoblock ID'):
         user.getUserPage()
     with self.assertRaisesRegex(AutoblockUserError,
                                 'This is an autoblock ID'):
         user.getUserTalkPage()
Esempio n. 4
0
 def test_autoblocked_user(self):
     """Test autoblocked user."""
     with patch.object(pywikibot, 'output') as p:
         user = User(self.site, '#1242976')
     p.assert_called_once_with(
         'This is an autoblock ID, you can only use to unblock it.')
     self.assertEqual('#1242976', user.username)
     with suppress_warnings('pywikibot.page.User.name is deprecated'):
         self.assertEqual(user.name(), user.username)
     self.assertEqual(user.title(with_ns=False), user.username[1:])
     self.assertFalse(user.isRegistered())
     self.assertFalse(user.isAnonymous())
     self.assertIsNone(user.registration())
     self.assertFalse(user.isEmailable())
     self.assertIn('invalid', user.getprops())
     self.assertTrue(user._isAutoblock)
     with self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID'):
         user.getUserPage()
     with self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID'):
         user.getUserTalkPage()