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 isEligibleAsGreeter(self, greeter: pywikibot.User) -> bool: if not greeter.isRegistered(): pywikibot.warning(f"Greeter '{greeter.username}' does not exist.") return False if greeter.isBlocked(): pywikibot.warning( f"'{greeter.username}' is blocked and thus not eligible as greeter." ) return False if self.isUserGloballyLocked(greeter): pywikibot.warning( f"'{greeter.username}' is globally locked and thus not eligible as greeter." ) return False if not "review" in greeter.getprops()["rights"]: pywikibot.warning( f"'{greeter.username}' does not have review rights and is thus not eligible as greeter." ) return False if greeter.getUserTalkPage().protection(): # Talk page is protected, thus not eligible as greeter return False if not inProduction and greeter.username != "Count Count": return False cutoffTime = datetime.now() - timedelta(hours=24) lastActivityTimestamp = greeter.last_event.timestamp() if lastActivityTimestamp < cutoffTime: # not active in the last 24 hours and is thus not eligible as greeter return False return True
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_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 checkGeneralEligibilityForPromotion( self, user: pywikibot.User) -> List[CriteriaCheck]: criteriaChecks = [] if user.isBlocked(): criteriaChecks.append( CriteriaCheck(False, "Benutzer ist gesperrt.")) else: criteriaChecks.append( CriteriaCheck(True, "Benutzer ist nicht gesperrt.")) if self.site.isBot(user.username): criteriaChecks.append(CriteriaCheck(False, "Benutzer ist ein Bot.")) else: criteriaChecks.append(CriteriaCheck(True, "Benutzer ist kein Bot.")) return criteriaChecks