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())
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())
def test_invalid_user(self): """Test invalid user.""" user = User(self.site, 'Invalid char\x9f in Name') self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertIn('invalid', user.getprops())
def test_anonymous_user(self): """Test registered user.""" user = User(self.site, '123.45.67.89') self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertTrue(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertIn('invalid', user.getprops())
def test_unregistered_user(self): """Test unregistered user.""" user = User(self.site, 'This user name is not registered yet') self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertIn('missing', user.getprops())
def test_registered_user(self): """Test registered user.""" user = User(self.site, 'Xqt') 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.assertIn('userid', user.getprops())
def test_unregistered_user(self): """Test unregistered user.""" user = User(self.site, 'This user name is not registered yet') with suppress_warnings('pywikibot.page.User.name', DeprecationWarning): self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertEqual(user.gender(), 'unknown') self.assertIn('missing', user.getprops())
def test_invalid_user(self): """Test invalid user.""" user = User(self.site, 'Invalid char\x9f in Name') with suppress_warnings('pywikibot.page.User.name', DeprecationWarning): self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertEqual(user.gender(), 'unknown') self.assertIn('invalid', user.getprops())
def test_unregistered_user(self): """Test unregistered user.""" user = User(self.site, 'This user name is not registered yet') with suppress_warnings('pywikibot.page.User.name', DeprecationWarning): self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertEqual(user.gender(), 'unknown') self.assertIn('missing', user.getprops()) self.assertFalse(user.is_thankable)
def test_anonymous_user(self): """Test registered user.""" user = User(self.site, '123.45.67.89') with suppress_warnings('pywikibot.page.User.name', DeprecationWarning): self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username) self.assertFalse(user.isRegistered()) self.assertTrue(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertEqual(user.gender(), 'unknown') self.assertIn('invalid', user.getprops()) self.assertFalse(user.is_thankable)
def test_anonymous_user(self): """Test registered user.""" user = User(self.site, '123.45.67.89') with suppress_warnings('pywikibot.page.User.name', DeprecationWarning): self.assertEqual(user.name(), user.username) self.assertEqual(user.title(with_ns=False), user.username) self.assertFalse(user.isRegistered()) self.assertTrue(user.isAnonymous()) self.assertIsNone(user.registration()) self.assertFalse(user.isEmailable()) self.assertEqual(user.gender(), 'unknown') self.assertIn('invalid', user.getprops()) self.assertFalse(user.is_thankable)
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())
def test_autoblocked_user_with_namespace(self): """Test autoblocked user.""" user = User(self.site, 'User:#1242976') self.assertEqual('#1242976', user.username) self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=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) self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID', user.getUserPage) self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID', user.getUserTalkPage)
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) 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) self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID', user.getUserPage) self.assertRaisesRegex(AutoblockUser, 'This is an autoblock ID', user.getUserTalkPage)