util testleri ekleyelim bir iki tane, kafamız rahat olsun..
This commit is contained in:
Binary file not shown.
Binary file not shown.
Symlink
+1
@@ -0,0 +1 @@
|
||||
arfilewithtimestamps.a
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/there/is/no/such/place
|
||||
@@ -9,6 +9,7 @@
|
||||
#
|
||||
|
||||
import unittest
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from pisi import version
|
||||
@@ -31,5 +32,29 @@ class UtilTestCase(unittest.TestCase):
|
||||
a = removepathprefix('usr/local/', 'usr/local/lib')
|
||||
self.assertEqual(a, 'lib')
|
||||
|
||||
def testCleanArTimestamp(self):
|
||||
shutil.copy('tests/utilfiles/arfilewithtimestamps.a', 'tests/utilfiles/cleanedarfile.a')
|
||||
clean_ar_timestamps('tests/utilfiles/cleanedarfile.a')
|
||||
for line in open('tests/utilfiles/cleanedarfile.a').readlines():
|
||||
pos = line.rfind(chr(32) + chr(96))
|
||||
if pos > -1 and line[pos-57:pos + 2].find(chr(47)) > -1:
|
||||
self.assertEqual(line[pos-41:pos].split()[0], "0000000000")
|
||||
|
||||
os.remove('tests/utilfiles/cleanedarfile.a')
|
||||
|
||||
def testDirSize(self):
|
||||
self.assertEqual(dir_size('tests/utilfiles/arfilewithtimestamps.a'), 74536)
|
||||
self.assertEqual(dir_size('tests/utilfiles/linktonowhere'), 23)
|
||||
self.assertEqual(dir_size('tests/utilfiles/directory'), 74536)
|
||||
self.assertEqual(dir_size('tests/utilfiles/linktoarfile'), 22)
|
||||
self.assertEqual(dir_size('tests/utilfiles/'), 149117)
|
||||
|
||||
def testGetFileHashes(self):
|
||||
self.assertEqual(len([x for x in get_file_hashes('tests/utilfiles/')]), 4)
|
||||
for tpl in get_file_hashes('tests/utilfiles/'):
|
||||
if os.path.basename(tpl[0]) == 'linktonowhere':
|
||||
self.assertEqual(tpl[1], '2d3732ababb24b5dd040a192dc72841cb9684d4e')
|
||||
if os.path.basename(tpl[0]) == 'linktoarfile':
|
||||
self.assertEqual(tpl[1], '8be108bc4bfb7d18a10da6d6b76060f0409dc7c6')
|
||||
|
||||
suite = unittest.makeSuite(UtilTestCase)
|
||||
|
||||
Reference in New Issue
Block a user