diff options
Diffstat (limited to 'test/test1.py')
-rw-r--r-- | test/test1.py | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/test/test1.py b/test/test1.py index 8e5cd1e..a42e9a5 100644 --- a/test/test1.py +++ b/test/test1.py @@ -6,17 +6,59 @@ __date__ = "$Date: 2011/02/08 $" __copyright__ = "Copyright (c) 2011 Joshua Ismael Haase Hernández" __license__ = "GPL3+" -import repm.filter +from repm.config import * +from repm.filter import * import unittest -import commands class KnownValues(unittest.TestCase): + directory_list=("drwxrwxr-x 15 2010/09/11 11:28:50 community-staging", + "drwxrwxr-x 30 2010/09/11 11:28:50 community-staging/os") + # (output, name, version, arch) + link_list=( + ("lrwxrwxrwx 53 2011/01/31 01:52:06 community-testing/os/i686/apvlv-0.1.0-2-i686.pkg.tar.xz -> ../../../pool/community/apvlv-0.1.0-2-i686.pkg.tar.xz", "apvlv","0.1.0","i686"), + ("lrwxrwxrwx 56 2011/02/04 14:34:08 community-testing/os/i686/calibre-0.7.44-2-i686.pkg.tar.xz -> ../../../pool/community/calibre-0.7.44-2-i686.pkg.tar.xz","calibre","0.7.44","i686"), + ) + package_list=( + ("-rw-rw-r-- 5846249 2010/11/13 10:54:25 pool/community/abuse-0.7.1-1-x86_64.pkg.tar.gz", + "abuse","0.7.1","x86_64"), + ("-rw-rw-r-- 982768 2011/02/05 14:38:17 pool/community/acetoneiso2-2.3-2-i686.pkg.tar.xz", + "acetoneiso2","2.3","i686"), + ("-rw-rw-r-- 982764 2011/02/05 14:38:40 pool/community/acetoneiso2-2.3-2-x86_64.pkg.tar.xz", + "acetoneiso2","2.3","x86_64") + ) + + def generate_results(example_tuple): + a=list() + for output, name, version, arch in example_tuple: + pkg=Packages() + pkg["name"] = name + pkg["version"] = version + pkg["arch"] = arch + a.append(pkg) + return tuple(a) def testDirectoryOutput(self): """get_file_list_from_rsync_output should ignore directories""" - output=commands.getoutput("cat ./directory_list") + rsync_out="\n".join(directory_list) result=get_file_list_from_rsync_output(output) self.assertEqual(tuple(), result) + def testLinkOutput(self): + """get_file_list_from_rsync_output should make a Package Object + from links """ + correct_result=generate_results(link_list) + rsync_out="\n".join([a for a,b,c,d in link_list]) + result=get_file_list_from_rsync_output(rsync_out) + self.assertEqual(correct_result, result) + + + def testPackageOutput(self): + """get_file_list_from_rsync_output should make a Package Object + from links """ + correct_result=generate_results(package_list) + rsync_out="\n".join([a for a,b,c,d in package_list]) + result=get_file_list_from_rsync_output(rsync_out) + self.assertEqual(correct_result, result) + if __name__ == "__main__": unittest.main() |