def testCounterRange(self): s1 = ShardCounterGenerator(start=0,length=5) s2 = ShardCounterGenerator(start=5,length=5) for i in range(1,6): self.assertEquals(s1.next(),i) self.assertEquals(s2.next(),i+5) self.assertEquals(s1.next(),None) self.assertEquals(s2.next(),None)
def testCounterNoNext(self): s = ShardCounterGenerator(start=0,length=1) self.assertEquals(1,s.next()) self.assertFalse(s.hasNext())
def testCounterLimit(self): s = ShardCounterGenerator(start=0,length=5) for i in range(1,6): self.assertEquals(s.next(),i) self.assertEquals(s.next(),None)
def testSimpleShardWorks(self): s = ShardCounterGenerator(start=0) self.assertEquals(s.next(),1)