summaryrefslogtreecommitdiff
path: root/python/samba/tests
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2018-12-03 17:22:43 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-12-12 04:38:13 +0100
commit629a41fc6542cda9c2d60f99e8d7856aa1e081e5 (patch)
tree27f9821f84e306a7889a089fe250fe37188ae11a /python/samba/tests
parentb84cea18fcc54f599db9580fd027b8d530d6b4bd (diff)
downloadsamba-629a41fc6542cda9c2d60f99e8d7856aa1e081e5.tar.gz
tests: Extend SMB Py binding .list() test-case
Extend the tests to better reflect some of the .list() functionality we expect. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba/tests')
-rw-r--r--python/samba/tests/smb.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py
index e4366ce7b52..70d6cd8ef2d 100644
--- a/python/samba/tests/smb.py
+++ b/python/samba/tests/smb.py
@@ -53,11 +53,33 @@ class SMBTests(samba.tests.TestCase):
pass
def test_list(self):
+ # check a basic listing returns the items we expect
ls = [f['name'] for f in self.conn.list(addom)]
self.assertIn('scripts', ls,
msg='"scripts" directory not found in sysvol')
self.assertIn('Policies', ls,
msg='"Policies" directory not found in sysvol')
+ self.assertNotIn('..', ls,
+ msg='Parent (..) found in directory listing')
+ self.assertNotIn('.', ls,
+ msg='Current dir (.) found in directory listing')
+
+ # using a '*' mask should be the same as using no mask
+ ls_wildcard = [f['name'] for f in self.conn.list(addom, "*")]
+ self.assertEqual(ls, ls_wildcard)
+
+ # applying a mask should only return items that match that mask
+ ls_pol = [f['name'] for f in self.conn.list(addom, "Pol*")]
+ expected = ["Policies"]
+ self.assertEqual(ls_pol, expected)
+
+ # each item in the listing is a has with expected keys
+ expected_keys = ['attrib', 'mtime', 'name', 'short_name', 'size']
+ for item in self.conn.list(addom):
+ for key in expected_keys:
+ self.assertIn(key, item,
+ msg="Key '%s' not in listing '%s'" % (key, item))
+
def file_exists(self, filepath):
"""Returns whether a regular file exists (by trying to open it)"""