PEP8: fix E703: statement ends with a semicolon
[nivanova/samba-autobuild/.git] / python / samba / tests / smb.py
index 4df83233357004ca13320819f4b6da02577131e7..e0e60e37102737a9e827b7bf1fb6aae10e227dfe 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import samba, os, random, sys
+import samba
+import os
+import random
+import sys
 from samba import smb
 
 PY3 = sys.version_info[0] == 3
 addom = 'addom.samba.example.com/'
-test_contents = 'abcd'*256
-utf_contents = u'Süßigkeiten Äpfel '*128
-test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64'*256
+test_contents = 'abcd' * 256
+utf_contents = u'Süßigkeiten Äpfel ' * 128
+test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64' * 256
 binary_contents = b'\xff\xfe'
-binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8')*128
-test_dir = os.path.join(addom, 'testing_%d' % random.randint(0,0xFFFF))
+binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8') * 128
+test_dir = os.path.join(addom, 'testing_%d' % random.randint(0, 0xFFFF))
 test_file = os.path.join(test_dir, 'testing').replace('/', '\\')
 
+
 class SMBTests(samba.tests.TestCase):
     def setUp(self):
         super(SMBTests, self).setUp()
@@ -49,9 +53,17 @@ class SMBTests(samba.tests.TestCase):
     def test_list(self):
         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')
+                      msg='"scripts" directory not found in sysvol')
+        self.assertIn('Policies', ls,
+                      msg='"Policies" directory not found in sysvol')
+
+    def test_unlink(self):
+        """
+        The smb.unlink API should delete file
+        """
+        self.conn.savefile(test_file, binary_contents)
+        self.conn.unlink(test_file)
+        self.assertFalse(self.conn.chkpath(test_file))
 
     def test_save_load_text(self):
 
@@ -59,7 +71,7 @@ class SMBTests(samba.tests.TestCase):
 
         contents = self.conn.loadfile(test_file)
         self.assertEquals(contents.decode('utf8'), test_contents,
-            msg='contents of test file did not match what was written')
+                          msg='contents of test file did not match what was written')
 
     # with python2 this will save/load str type (with embedded nulls)
     # with python3 this will save/load bytes type
@@ -68,7 +80,7 @@ class SMBTests(samba.tests.TestCase):
 
         contents = self.conn.loadfile(test_file)
         self.assertEquals(contents, test_literal_bytes_embed_nulls,
-            msg='contents of test file did not match what was written')
+                          msg='contents of test file did not match what was written')
 
     # python3 only this will save/load unicode
     def test_save_load_utfcontents(self):
@@ -77,13 +89,13 @@ class SMBTests(samba.tests.TestCase):
 
             contents = self.conn.loadfile(test_file)
             self.assertEquals(contents.decode('utf8'), utf_contents,
-                msg='contents of test file did not match what was written')
+                              msg='contents of test file did not match what was written')
 
     # with python2 this will save/load str type
     # with python3 this will save/load bytes type
     def test_save_binary_contents(self):
-        self.conn.savefile(test_file, binary_contents);
+        self.conn.savefile(test_file, binary_contents)
 
         contents = self.conn.loadfile(test_file)
         self.assertEquals(contents, binary_contents,
-            msg='contents of test file did not match what was written')
+                          msg='contents of test file did not match what was written')