remove tests with too many votes
This commit is contained in:
parent
5f71b735e5
commit
b2bc582f92
@ -75,18 +75,6 @@ class TestVote(unittest.TestCase):
|
|||||||
self.assertEqual(rv.status_code, 200)
|
self.assertEqual(rv.status_code, 200)
|
||||||
self.assertEqual(loads(rv.data), None)
|
self.assertEqual(loads(rv.data), None)
|
||||||
|
|
||||||
def testTooManyLikes(self):
|
|
||||||
|
|
||||||
self.makeClient("127.0.0.1").post("/new?uri=test", data=json.dumps({"text": "..."}))
|
|
||||||
for num in range(256):
|
|
||||||
rv = self.makeClient("1.2.%i.0" % num).post('/id/1/like')
|
|
||||||
self.assertEqual(rv.status_code, 200)
|
|
||||||
|
|
||||||
if num >= 142:
|
|
||||||
self.assertEqual(loads(rv.data)["likes"], 142)
|
|
||||||
else:
|
|
||||||
self.assertEqual(loads(rv.data)["likes"], num + 1)
|
|
||||||
|
|
||||||
def testDislike(self):
|
def testDislike(self):
|
||||||
self.makeClient("127.0.0.1").post("/new?uri=test", data=json.dumps({"text": "..."}))
|
self.makeClient("127.0.0.1").post("/new?uri=test", data=json.dumps({"text": "..."}))
|
||||||
rv = self.makeClient("1.2.3.4").post('/id/1/dislike')
|
rv = self.makeClient("1.2.3.4").post('/id/1/dislike')
|
||||||
|
@ -33,7 +33,7 @@ def anonymize(remote_addr):
|
|||||||
return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000']*5)
|
return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000']*5)
|
||||||
|
|
||||||
|
|
||||||
class Bloomfilter:
|
class Bloomfilter(object):
|
||||||
"""A space-efficient probabilistic data structure. False-positive rate:
|
"""A space-efficient probabilistic data structure. False-positive rate:
|
||||||
|
|
||||||
* 1e-05 for <80 elements
|
* 1e-05 for <80 elements
|
||||||
@ -46,7 +46,7 @@ class Bloomfilter:
|
|||||||
|
|
||||||
>>> bf = Bloomfilter()
|
>>> bf = Bloomfilter()
|
||||||
>>> bf.add("127.0.0.1")
|
>>> bf.add("127.0.0.1")
|
||||||
>>> not any(map(bf.__contains__, ("1.2.%i.4" for i in range(256))))
|
>>> not any(addr in bf for addr in ("1.2.%i.4" for i in range(256)))
|
||||||
True
|
True
|
||||||
|
|
||||||
>>> bf = Bloomfilter()
|
>>> bf = Bloomfilter()
|
||||||
|
Loading…
Reference in New Issue
Block a user