summaryrefslogtreecommitdiff
path: root/source4/bin/python
diff options
context:
space:
mode:
Diffstat (limited to 'source4/bin/python')
-rw-r--r--source4/bin/python/samba/tests/shares.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/source4/bin/python/samba/tests/shares.py b/source4/bin/python/samba/tests/shares.py
index 0a771b1754..9130c36780 100644
--- a/source4/bin/python/samba/tests/shares.py
+++ b/source4/bin/python/samba/tests/shares.py
@@ -20,15 +20,47 @@ from samba.shares import SharesContainer
from unittest import TestCase
+class MockService(object):
+
+ def __init__(self, data):
+ self.data = data
+
+ def __getitem__(self, name):
+ return self.data[name]
+
+
+class MockLoadParm(object):
+
+ def __init__(self, data):
+ self.data = data
+
+ def __getitem__(self, name):
+ return MockService(self.data[name])
+
+ def __contains__(self, name):
+ return name in self.data
+
+ def __len__(self):
+ return len(self.data)
+
+ def services(self):
+ return self.data.keys()
+
+
class ShareTests(TestCase):
def _get_shares(self, conf):
- return SharesContainer(conf)
+ return SharesContainer(MockLoadParm(conf))
def test_len_no_global(self):
shares = self._get_shares({})
self.assertEquals(0, len(shares))
+ def test_iter(self):
+ self.assertEquals([], list(self._get_shares({})))
+ self.assertEquals([], list(self._get_shares({"global":{}})))
+ self.assertEquals(["bla"], list(self._get_shares({"global":{}, "bla":{}})))
+
def test_len(self):
shares = self._get_shares({"global": {}})
self.assertEquals(0, len(shares))