def testIterReverseMiddle(self): self.e.put('a', '') self.e.put('b', '') self.e.put('d', '') self.e.put('e', '') eq(strize(self.e.iter('c', True)), [('d', ''), ('b', ''), ('a', '')])
def do_test(self, k): packed = keylib.packs(k) try: unpacked = keylib.unpack(packed) eq(k, keylib.unpack(keylib.packs(k))) except: print 'failing enc was: %r' % (packed,) raise
def test_delete_pop(self): self.insert_items() self.coll.strategy.batch(max_recs=len(self.ITEMS)) # Pop should trigger split of batch and return of old value. data = self.coll.strategy.pop(self.txn.get(), keylib.Key(3)) eq(data, '"jim"') # Should now contain metadata + 2 remaining records. assert len(self.e.items) == (self.old_len + 2)
def test1(self): for i in self.INTS: s = keylib.packs(i) try: j, = keylib.unpack(s) eq(j, i) except: print [i, s] raise
def test1(self): for i in EncodeIntTest.INTS: native = _keylib.packs(i) python = keylib.packs(i) try: eq(native, python) except: print 'failing int was ' + str(i) raise
def test_pos(self): tz = dateutil.tz.gettz('Etc/GMT+1') dt = datetime.now(tz) sn = _keylib.packs(dt) sp = keylib.packs(dt) eq(sn, sp) dn = _keylib.unpacks(sn) dp = keylib.unpacks(sp) eq(dn, dp)
def test1(self): for seq in self.SEQS: packed = map(lambda s: keylib.packs(s), seq) rnge = range(len(packed)) done = sorted(rnge, key=packed.__getitem__) try: eq(done, rnge) except: print 'failed:', seq raise
def testGetExist(self): key = self.coll.put(u'') eq(key, (1, )) eq('', self.coll.get(1)) key = self.coll.put(u'x') eq(key, (2, )) eq(u'x', self.coll.get(2))
def testGetExist(self): key = self.coll.put(u'') eq(key, (1,)) eq('', self.coll.get(1)) key = self.coll.put(u'x') eq(key, (2,)) eq(u'x', self.coll.get(2))
def test_max_1(self): self.rit.set_max(1) eq([BPKEYS[0]], keyfrom(self.rit.forward))
def testReverseSkipMostExist(self): eq([([('aa',)], '')], self.riter('ab'))
def testReverseSeekExist(self): eq(self.REVERSE[2:], self.riter(hi='dd'))
def test_lo_closed_nomatch_sof(self): self.rit.set_lo('0', closed=True) eq(PKEYS, key0from(self.rit.forward)) eq(RPKEYS, key0from(self.rit.reverse))
def test_max_phys_1_reverse(self): self.rit.set_max_phys(1) # Last physical record is non-batch. eq(RBPKEYS[:1], keyfrom(self.rit.reverse))
def testIterValues(self): eq([u'dave', u'dave2'], list(self.i.values())) eq([u'dave2', u'dave'], list(self.i.values(reverse=True)))
def testIterItems(self): item1 = (self.key, u'dave') item2 = (self.key2, u'dave2') eq([item1, item2], list(self.i.items())) eq([item2, item1], list(self.i.items(reverse=True)))
def testIterKeys(self): eq([self.key, self.key2], list(self.i.keys())) eq([self.key2, self.key], list(self.i.keys(reverse=True)))
def testIterTups(self): eq([(69, u'dave'), (69, u'dave2')], list(self.i.tups())) eq([(69, u'dave2'), (69, u'dave')], list(self.i.tups(reverse=True)))
def testIterPairs(self): eq(self.both, list(self.i.pairs())) eq(self.both, list(self.i.pairs(lo=68))) eq(self.both, list(self.i.pairs(lo=(69, u'dave')))) eq(self.second, list(self.i.pairs(lo=(69, u'dave2')))) eq([], list(self.i.pairs(lo=80))) eq(self.both[::-1], list(self.i.pairs(reverse=True))) self.coll.delete(self.key) eq(self.second, list(self.i.pairs())) self.coll.delete(self.key2) eq([], list(self.i.pairs()))
def test_max_2(self): self.rit.set_max(2) eq(2, len(list(self.rit.forward())))
def test_max_1_reverse_open_hi(self): self.rit.set_max(1) self.rit.set_hi('D', closed=False) eq([RBPKEYS[1]], keyfrom(self.rit.reverse))
def testFind(self): eq(u'dave', self.i.find()) eq(u'dave2', self.i.find(reverse=True)) eq(u'dave2', self.i.find((69, u'dave2'))) # open eq(u'dave', self.i.find(hi=(69, u'dave2'), reverse=True))
def test_max_phys_2_reverse(self): self.rit.set_max_phys(2) # Last 2 records contain 4 keys. eq(RBPKEYS[:4], keyfrom(self.rit.reverse))
def testGet(self): eq(None, self.i.get('missing')) eq(u'dave', self.i.get((69, u'dave'))) eq(u'dave2', self.i.get((69, u'dave2')))
def test_lo_closed_match(self): self.rit.set_lo('B', closed=True) eq(PKEYS[1:], key0from(self.rit.forward)) eq(RPKEYS[:-1], key0from(self.rit.reverse))
def test_lo_open_nomatch(self): self.rit.set_lo('BA', closed=False) eq(BPKEYS[2:], keyfrom(self.rit.forward)) eq(RBPKEYS[:-2], keyfrom(self.rit.reverse))
def testReverseSeekNoExistInclude(self): eq(self.REVERSE[1:], self.riter('ddd'))
def test_hi_closed_nomatch_eof(self): self.rit.set_hi('a', closed=True) eq(BPKEYS, keyfrom(self.rit.forward)) eq(RBPKEYS, keyfrom(self.rit.reverse))
def testReverseSeekExistInclude(self): eq(self.REVERSE[1:], self.riter(hi='dd', include=True))
def test_exact_closed_match(self): self.rit.set_exact('B') eq([BPKEYS[1]], keyfrom(self.rit.forward)) eq([RBPKEYS[-2]], keyfrom(self.rit.reverse))
def test_lo_open_nomatch_eof(self): self.rit.set_lo('a', closed=False) eq([], keyfrom(self.rit.forward)) eq([], keyfrom(self.rit.reverse))
def test_no_max(self): eq(BPKEYS, keyfrom(self.rit.forward))
def test_hi_closed_nomatch_sof(self): self.rit.set_hi('0', closed=True) eq([], keyfrom(self.rit.forward)) eq([], keyfrom(self.rit.reverse))
def testNoExistNoCount(self): eq(10, self.store.count('test', n=0, init=10)) eq(10, self.store.count('test', n=0, init=10))
def test_hi_closed_nomatch(self): self.rit.set_hi('BA', closed=True) eq(BPKEYS[:2], keyfrom(self.rit.forward)) eq(RBPKEYS[-2:], keyfrom(self.rit.reverse))
def testExistCountSometimes(self): eq(10, self.store.count('test', init=10)) eq(11, self.store.count('test', n=0, init=10)) eq(11, self.store.count('test', init=10)) eq(12, self.store.count('test', init=10)) eq(self.e.iter_count, 0) eq(self.e.get_count, 4) eq(self.e.put_count, 3)
def test_exact_closed_nomatch(self): self.rit.set_exact('BA') eq([], keyfrom(self.rit.forward)) eq([], keyfrom(self.rit.reverse))
def testForward(self): eq(self.ITEMS, self.iter())
def test_no_max_reverse(self): eq(RBPKEYS, keyfrom(self.rit.reverse))
def testForwardSeekFirst(self): eq(self.ITEMS, self.iter('aa'))
def test_max_1_reverse(self): self.rit.set_max(1) eq([RBPKEYS[0]], keyfrom(self.rit.reverse))
def testForwardSeekNoExist(self): eq(self.ITEMS[1:], self.iter('b'))
def test_max_1_open_lo(self): self.rit.set_max(1) self.rit.set_lo('A', closed=False) eq([BPKEYS[1]], keyfrom(self.rit.forward))
def testForwardSeekExist(self): eq(self.ITEMS[1:], self.iter('cc'))
def test_max_phys_1_forward(self): self.rit.set_max_phys(1) # First physical record is a batch of 2 keys. eq(BPKEYS[:2], keyfrom(self.rit.forward))
def testForwardSkipMostExist(self): eq([([('de',),], '')], self.iter('de'))
def test_max_phys_2_forward(self): self.rit.set_max_phys(2) # First 2 records contain 3 keys. eq(BPKEYS[:3], keyfrom(self.rit.forward))
def testForwardSeekBeyondNoExist(self): eq([], self.iter('df'))
def test_max_lo_non_batch(self): # Begin iteration from non-batch record. self.rit.set_lo('BB', closed=True) # Continue for 2 physical records (BB, BC, BD) self.rit.set_max_phys(2) eq(BPKEYS[2:5], keyfrom(self.rit.forward))
def testReverseAutoInclude(self): eq(self.REVERSE, self.riter('de'))
def test_lo_closed_nomatch_eof(self): self.rit.set_lo('a', closed=True) eq([], key0from(self.rit.forward)) eq([], key0from(self.rit.reverse))
def testReverseSeekLast(self): eq(self.REVERSE[1:], self.riter(hi='de'))
import tentapp tentapp.debug = False print yellow( '-----------------------------------------------------------------------\\' ) testlib.begin('TentApp') #------------------------------------------------------------------------------------------- #--- AUTHENTICATION entityUrl = 'https://pythonclienttest.tent.is' app = tentapp.TentApp(entityUrl) testlib.eq(app.hasRegistrationKeys(), False, 'when starting, should not have registration keys') testlib.eq(app.hasPermanentKeys(), False, 'when starting, should not have permanent keys') # We use the result of getFollowers to see if we're actually authenticated or not # The resulting JSON objects will have a "groups" field if and only if the authentication is working. aFollower = app.getFollowers()[0] testlib.eq('groups' in aFollower, False, 'non-authenticated GET /followers should not have "groups"') # Generators with no authentication try: generator = app.generateFollowers() firstItem = generator.next() testlib.passs() except:
def testReverseSeekLastInclude(self): eq(self.REVERSE, self.riter('de', include=True))