From b2bc582f92e8f4ae42b2531f9f5d669a2ad437a3 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 25 Jun 2014 19:07:19 +0200 Subject: [PATCH] remove tests with too many votes --- isso/tests/test_vote.py | 12 ------------ isso/utils/__init__.py | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/isso/tests/test_vote.py b/isso/tests/test_vote.py index 4266654..e90686e 100644 --- a/isso/tests/test_vote.py +++ b/isso/tests/test_vote.py @@ -75,18 +75,6 @@ class TestVote(unittest.TestCase): self.assertEqual(rv.status_code, 200) 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): 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') diff --git a/isso/utils/__init__.py b/isso/utils/__init__.py index 9a50a79..dfc361c 100644 --- a/isso/utils/__init__.py +++ b/isso/utils/__init__.py @@ -33,7 +33,7 @@ def anonymize(remote_addr): return u'' + ipv6.exploded.rsplit(':', 5)[0] + ':' + ':'.join(['0000']*5) -class Bloomfilter: +class Bloomfilter(object): """A space-efficient probabilistic data structure. False-positive rate: * 1e-05 for <80 elements @@ -46,7 +46,7 @@ class Bloomfilter: >>> bf = Bloomfilter() >>> 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 >>> bf = Bloomfilter()