]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Expands leasedb tests
authorMark Berger <mark.berger.j@gmail.com>
Fri, 26 Jul 2013 18:26:48 +0000 (14:26 -0400)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 5 May 2014 18:29:43 +0000 (19:29 +0100)
src/allmydata/test/test_leasedb.py

index d95524dc8d3e7aa8632f95dc9f458f961d41f196..5b163608c831c5eb625729eb5a2f3c4219b3ed59 100644 (file)
@@ -86,6 +86,29 @@ class DB(unittest.TestCase):
                               "INSERT INTO `leases` VALUES(?,?,?,?,?)",
                               ('si1', 0,  LeaseDB.ANONYMOUS_ACCOUNTID, 0, 0))
 
+        num_shares, total_leased_used_space = l.get_total_leased_sharecount_and_used_space()
+        num_sharesets = l.get_number_of_sharesets()
+        self.failUnlessEqual(total_leased_used_space, 12345)
+        self.failUnlessEqual(num_shares, 1)
+        self.failUnlessEqual(num_sharesets, 1)
+
+        l.add_new_share('si1', 1, 12345, SHARETYPE_IMMUTABLE)
+        l.add_starter_lease('si1', 1)
+        num_shares, total_leased_used_space = l.get_total_leased_sharecount_and_used_space()
+        num_sharesets = l.get_number_of_sharesets()
+        self.failUnlessEqual(total_leased_used_space, 24690)
+        self.failUnlessEqual(num_shares, 2)
+        self.failUnlessEqual(num_sharesets, 1)
+
+        l.add_new_share('si2', 0, 12345, SHARETYPE_IMMUTABLE)
+        l.add_starter_lease('si2', 0)
+        num_sharesets = l.get_number_of_sharesets()
+        num_shares, total_leased_used_space = l.get_total_leased_sharecount_and_used_space()
+        num_sharesets = l.get_number_of_sharesets()
+        self.failUnlessEqual(total_leased_used_space, 37035)
+        self.failUnlessEqual(num_shares, 3)
+        self.failUnlessEqual(num_sharesets, 2)
+
 class MockCursor:
     def __init__(self):
         self.closed = False