ActionsAPI içindeki copy için unittestler..
Artık bizi en çok sinir eden api bileşenlerinden birisi ile daha kolay başa çıkabileceğiz umuyorum..
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
import unittest
|
||||
import zipfile
|
||||
import shutil
|
||||
import os
|
||||
|
||||
import testcase
|
||||
|
||||
@@ -55,4 +57,52 @@ class ActionsAPITestCase(testcase.TestCase):
|
||||
for file in self.filelist:
|
||||
self.assert_(fileContent.__contains__(file))
|
||||
|
||||
def testShellToolsCopy(self):
|
||||
from pisi.actionsapi.shelltools import copy
|
||||
|
||||
copy('tests/actionsapitests/brokenlink', 'tests/actionsapitests/brokenlink-copy')
|
||||
self.assertEqual(os.path.islink('tests/actionsapitests/brokenlink-copy'), True)
|
||||
os.remove('tests/actionsapitests/brokenlink-copy')
|
||||
|
||||
copy('tests/actionsapitests/brokenlink', 'tests/actionsapitests/adirectory')
|
||||
self.assertEqual(os.path.islink('tests/actionsapitests/adirectory/brokenlink'), True)
|
||||
|
||||
copy('tests/actionsapitests/brokenlink', 'tests/actionsapitests/adirectory/bl')
|
||||
self.assertEqual(os.path.islink('tests/actionsapitests/adirectory/bl'), True)
|
||||
os.remove('tests/actionsapitests/adirectory/bl')
|
||||
|
||||
self.assertEqual(os.readlink('tests/actionsapitests/adirectory/brokenlink'), '/no/such/place')
|
||||
os.remove('tests/actionsapitests/adirectory/brokenlink')
|
||||
|
||||
copy('tests/actionsapitests/linktoadirectory', 'tests/actionsapitests/adirectory/', False)
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/adirectory/linkeddir/file'), True)
|
||||
self.assertEqual(os.path.getsize('tests/actionsapitests/adirectory/linkeddir/file'), 321)
|
||||
shutil.rmtree('tests/actionsapitests/adirectory/linkeddir')
|
||||
|
||||
copy('tests/actionsapitests/file', 'tests/actionsapitests/adirectory')
|
||||
self.assertEqual(os.path.isfile('tests/actionsapitests/adirectory/file'), True)
|
||||
#overwrite..
|
||||
copy('tests/actionsapitests/file', 'tests/actionsapitests/adirectory')
|
||||
os.remove('tests/actionsapitests/adirectory/file')
|
||||
|
||||
copy('tests/actionsapitests/linktoafile', 'tests/actionsapitests/adirectory', False)
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/adirectory/%s' % (os.path.basename(os.readlink('tests/actionsapitests/linktoafile')))), True)
|
||||
os.remove('tests/actionsapitests/adirectory/%s' % (os.path.basename(os.readlink('tests/actionsapitests/linktoafile'))))
|
||||
|
||||
copy('tests/actionsapitests/file', 'tests/actionsapitests/file-copy')
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/file-copy'), True)
|
||||
os.remove('tests/actionsapitests/file-copy')
|
||||
|
||||
copy('tests/actionsapitests/file', 'tests/actionsapitests/adirectory/filewithanothername')
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/adirectory/filewithanothername'), True)
|
||||
os.remove('tests/actionsapitests/adirectory/filewithanothername')
|
||||
|
||||
copy('tests/actionsapitests/linkeddir', 'tests/actionsapitests/adirectory')
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/adirectory/linkeddir/file'), True)
|
||||
shutil.rmtree('tests/actionsapitests/adirectory/linkeddir')
|
||||
|
||||
copy('tests/actionsapitests/linkeddir', 'tests/actionsapitests/adirectory/withanothername')
|
||||
self.assertEqual(os.path.exists('tests/actionsapitests/adirectory/withanothername/file'), True)
|
||||
shutil.rmtree('tests/actionsapitests/adirectory/withanothername')
|
||||
|
||||
suite = unittest.makeSuite(ActionsAPITestCase)
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/no/such/place
|
||||
@@ -0,0 +1,6 @@
|
||||
toplam 4
|
||||
drwxr-xr-x 2 meren users 4096 Mar 10 12:55 adirectory
|
||||
lrwxrwxrwx 1 meren users 14 Mar 10 12:41 brokenlink -> /no/such/place
|
||||
-rw-r--r-- 1 meren users 0 Mar 10 12:57 file
|
||||
lrwxrwxrwx 1 meren users 4 Mar 10 12:42 linktoadirectory -> /etc
|
||||
lrwxrwxrwx 1 meren users 11 Mar 10 12:42 linktoafile -> /etc/passwd
|
||||
@@ -0,0 +1,6 @@
|
||||
toplam 4
|
||||
drwxr-xr-x 2 meren users 4096 Mar 10 12:55 adirectory
|
||||
lrwxrwxrwx 1 meren users 14 Mar 10 12:41 brokenlink -> /no/such/place
|
||||
-rw-r--r-- 1 meren users 0 Mar 10 12:57 file
|
||||
lrwxrwxrwx 1 meren users 4 Mar 10 12:42 linktoadirectory -> /etc
|
||||
lrwxrwxrwx 1 meren users 11 Mar 10 12:42 linktoafile -> /etc/passwd
|
||||
+1
@@ -0,0 +1 @@
|
||||
tests/actionsapitests/linkeddir/
|
||||
+1
@@ -0,0 +1 @@
|
||||
tests/actionsapitests/file
|
||||
Reference in New Issue
Block a user