コード例 #1
0
 def test_isblocked(self):
     api.logging = True
     u1 = user.User(self.site, "Vandal1", check=False)
     self.assertTrue(u1.isBlocked())
     self.assertEqual(len(api.querylog), 1)
     u1 = user.User(self.site, "Vandal1", check=True)
     self.assertTrue(u1.isBlocked())
     self.assertEqual(len(api.querylog), 2)
コード例 #2
0
 def test_constructor_IP(self):
     api.logging = True
     u1 = user.User(self.site, "123.45.67.89")
     self.assertEqual(len(api.querylog), 0)
     u2 = user.User(self.site, "1:2:3:4:5:6:7:8")
     self.assertEqual(len(api.querylog), 0)
     u3 = user.User(self.site, "123")
     self.assertEqual(len(api.querylog), 1)
     u4 = user.User(self.site, "300.1.1.1")
     self.assertEqual(len(api.querylog), 2)
     self.assertTrue(u1.isIP)
     self.assertTrue(u2.isIP)
     self.assertFalse(u3.isIP)
     self.assertFalse(u4.isIP)
コード例 #3
0
 def test_equality(self):
     u1 = page.Page(self.site, "GoodUsername", check=True)
     u2 = page.Page(self.site, "GoodUsername", check=False)
     self.assertEqual(u1, u2)
     site2 = wiki.Wiki("https://en.wikipedia.org/w/api.php")
     u3 = user.User(site2, "GoodUsername")
     self.assertNotEqual(u1, u3)
コード例 #4
0
 def test_getContributions(self):
     u1 = user.User(self.site, "GoodUsername")
     api.logging = True
     u1.getContributions(limit=10)
     self.assertIs(len(api.querylog), 1)
     c1 = api.querylog.pop()
     self.assertEqual(c1["ucdir"], "older")
コード例 #5
0
 def test_block(self):
     self.site.login("GoodUsername", "goodpassword")
     u1 = user.User(self.site, "Vandal2")
     api.logging = True
     res = u1.block(reason="test_block", autoblock=False, nocreate=False)
     self.assertEqual(res["block"]["expiry"], "infinite")
     log1 = api.querylog.pop()
     self.assertEqual(log1["action"], "query")
     self.assertEqual(log1["meta"], "tokens")
     log2 = api.querylog.pop()
     self.assertNotIn("autoblock", log2)
     self.assertNotIn("nocreate", log2)
     self.assertIn("reason", log2)
     res = u1.unblock()
     self.assertIn("unblock", res)
     self.assertEqual(len(api.querylog), 2)
コード例 #6
0
def donothing(*args):
    try:
        with wiki.Wiki('https://el.wiktionary.org/') as mywiki:
            print(mywiki)
            p = page.Page(mywiki, title='go')
            print(p)
            urldata = { 'action':'query',
            'list':'recentchanges',
            'rcprop':'title|timestamp|loginfo',
            'rctype':'log|edit|new',
            'rcdir':'newer',
            'rcstart':'20170703230000',
            #'continue':self.dummycontinue,
            #'rclimit':MAX_LE_OR_RC,
            'maxlag':MAX_LAG
            }
            therequest = api.APIRequest(mywiki, urldata)
            #thedict = {}
            print(therequest)
            u = user.User(mywiki,'')
            print(u)
            print(u.getContributions())
    except Exception as e:
        raise e
コード例 #7
0
 def test_hash(self):
     u1 = user.User(self.site, "GoodUsername", check=True)
     d = {u1: "Test"}
     u2 = user.User(self.site, "GoodUsername", check=False)
     self.assertTrue(u2 in d.keys())
コード例 #8
0
 def test_getContributionsGen(self):
     u1 = user.User(self.site, "GoodUsername")
     api.logging = True
     for log in u1.getContributionsGen(limit=5):
         pass
     self.assertGreater(len(api.querylog), 1)
コード例 #9
0
 def test_constructor_blocked(self):
     api.logging = True
     u1 = user.User(self.site, "Vandal1")
     self.assertEqual(len(api.querylog), 1)
     self.assertTrue(u1.blocked)
コード例 #10
0
 def test_constructor_notexists(self):
     api.logging = True
     u1 = user.User(self.site, "Doesn't exist")
     self.assertEqual(len(api.querylog), 1)
     self.assertFalse(u1.exists)