]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_storage_client.py: add test_get_available_space_{old,new}.
authorDaira Hopwood <daira@jacaranda.org>
Sun, 23 Nov 2014 05:46:33 +0000 (05:46 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Sun, 23 Nov 2014 06:03:00 +0000 (06:03 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_storage_client.py [new file with mode: 0644]

diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py
new file mode 100644 (file)
index 0000000..592e40e
--- /dev/null
@@ -0,0 +1,30 @@
+
+from twisted.trial import unittest
+from allmydata.storage_client import NativeStorageServer
+
+
+class NativeStorageServerWithVersion(NativeStorageServer):
+    def __init__(self,version):
+        self.version=version
+    def get_version(self):
+        return self.version
+
+
+class TestNativeStorageServer(unittest.TestCase):
+    def test_get_available_space_new(self):
+        nss = NativeStorageServerWithVersion(
+            { "http://allmydata.org/tahoe/protocols/storage/v1":
+                { "maximum-immutable-share-size": 111,
+                  "available-space": 222,
+                }
+            })
+        self.failUnlessEqual(nss.get_available_space(), 222)
+
+    def test_get_available_space_old(self):
+        nss = NativeStorageServerWithVersion(
+            { "http://allmydata.org/tahoe/protocols/storage/v1":
+                { "maximum-immutable-share-size": 111,
+                }
+            })
+        self.failUnlessEqual(nss.get_available_space(), 111)
+