summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2018-12-03 11:01:14 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-12-12 04:38:13 +0100
commitfa77209dea48c623fa3052a65b2d8dad9f146198 (patch)
tree67a9688f6b16310fb6742f2128f1934cdeb841a5 /python
parent35e1a7989d2af4508abe589ca4dcb1e73342b875 (diff)
downloadsamba-fa77209dea48c623fa3052a65b2d8dad9f146198.tar.gz
tests: Add SMB Py binding .chkpath() test case
chkpath was only tested incidentally (and that assertion was wrong). Add a proper test to prove it works correctly. We can then clean-up the incorrect assertion in the next patch. 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')
-rw-r--r--python/samba/tests/smb.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py
index e0e60e37102..6f33ff105fc 100644
--- a/python/samba/tests/smb.py
+++ b/python/samba/tests/smb.py
@@ -65,6 +65,26 @@ class SMBTests(samba.tests.TestCase):
self.conn.unlink(test_file)
self.assertFalse(self.conn.chkpath(test_file))
+ def test_chkpath(self):
+ """Tests .chkpath determines whether or not a directory exists"""
+
+ self.assertTrue(self.conn.chkpath(test_dir))
+
+ # should return False for a non-existent directory
+ bad_dir = self.make_sysvol_path(test_dir, 'dont_exist')
+ self.assertFalse(self.conn.chkpath(bad_dir))
+
+ # should return False for files (because they're not directories)
+ self.conn.savefile(test_file, binary_contents)
+ self.assertFalse(self.conn.chkpath(test_file))
+
+ # check correct result after creating and then deleting a new dir
+ new_dir = self.make_sysvol_path(test_dir, 'test-new')
+ self.conn.mkdir(new_dir)
+ self.assertTrue(self.conn.chkpath(new_dir))
+ self.conn.rmdir(new_dir)
+ self.assertFalse(self.conn.chkpath(new_dir))
+
def test_save_load_text(self):
self.conn.savefile(test_file, test_contents.encode('utf8'))
@@ -99,3 +119,7 @@ class SMBTests(samba.tests.TestCase):
contents = self.conn.loadfile(test_file)
self.assertEquals(contents, binary_contents,
msg='contents of test file did not match what was written')
+
+ def make_sysvol_path(self, dirpath, filename):
+ # return the dir + filename as a sysvol path
+ return os.path.join(dirpath, filename).replace('/', '\\')