summaryrefslogtreecommitdiff
path: root/test/test1.py
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-02-08 03:41:12 -0600
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-02-08 03:41:12 -0600
commit8fcf2f7f622de21b580ee808de53cffcc9200639 (patch)
tree4edf712e77a8b20b4c99f65af566b3eb4c0962c2 /test/test1.py
parent61f5ecfa6b57f31c14430a7de5099640fcbe3525 (diff)
Better testcases
Diffstat (limited to 'test/test1.py')
-rw-r--r--test/test1.py60
1 files changed, 32 insertions, 28 deletions
diff --git a/test/test1.py b/test/test1.py
index db87f51..4ec72d3 100644
--- a/test/test1.py
+++ b/test/test1.py
@@ -14,12 +14,10 @@ import unittest
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, release, location)
- link_list=(
+ # (rsync_out, name, version, arch, release, location)
+ examples=(
("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", "2", "community-testing/os/i686/apvlv-0.1.0-2-i686.pkg.tar.xz"),
("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", "2", "community-testing/os/i686/calibre-0.7.44-2-i686.pkg.tar.xz"),
- )
- 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","1","pool/community/abuse-0.7.1-1-x86_64.pkg.tar.gz"),
("-rw-rw-r-- 982768 2011/02/05 14:38:17 pool/community/acetoneiso2-2.3-2-i686.pkg.tar.xz",
@@ -29,16 +27,8 @@ class KnownValues(unittest.TestCase):
)
def generate_results(self, example_tuple):
- a=list()
- for output, name, version, arch, release, location in example_tuple:
- pkg=Package()
- pkg["name"] = name
- pkg["version"] = version
- pkg["arch"] = arch
- pkg["release"] = release
- pkg["location"] = location
- a.append(pkg)
- return tuple(a)
+ rsync_out="\n".join([a for a,b,c,d,e,f in example_tuple])
+ return get_file_list_from_rsync_output(rsync_out)
def testDirectoryOutput(self):
"""get_file_list_from_rsync_output should ignore directories"""
@@ -46,21 +36,35 @@ class KnownValues(unittest.TestCase):
result=get_file_list_from_rsync_output(rsync_out)
self.assertEqual(tuple(), result)
- def testLinkOutput(self):
- """get_file_list_from_rsync_output should make a Package Object
- from links """
- correct_result=self.generate_results(self.link_list)
- rsync_out="\n".join([a for a,b,c,d,e,f in self.link_list])
- result=get_file_list_from_rsync_output(rsync_out)
- self.assertEqual(correct_result, result)
+ def testNames(self):
+ results=self.generate_results(self.examples)
+ var =[name for rsync_out, name, version, arch, release, location in self.examples]
+ for i in range(len(results)):
+ self.assertEqual(results[i]["name"], var[i])
- def testPackageOutput(self):
- """get_file_list_from_rsync_output should make a Package Object
- from links """
- correct_result=self.generate_results(self.package_list)
- rsync_out="\n".join([a for a,b,c,d,e,f in self.package_list])
- result=get_file_list_from_rsync_output(rsync_out)
- self.assertEqual(correct_result, result)
+ def testVersions(self):
+ results=self.generate_results(self.examples)
+ var = [version for rsync_out, name, version, arch, release, location in self.examples]
+ for i in range(len(results)):
+ self.assertEqual(results[i]["name"], var[i])
+
+ def testArchs(self):
+ results=self.generate_results(self.examples)
+ var = [arch for rsync_out, name, version, arch, release, location in self.examples]
+ for i in range(len(results)):
+ self.assertEqual(results[i]["name"], var[i])
+
+ def testReleases(self):
+ results=self.generate_results(self.examples)
+ var = [release for rsync_out, name, version, arch, release, location in self.examples]
+ for i in range(len(results)):
+ self.assertEqual(results[i]["name"], var[i])
+
+ def testLocations(self):
+ results=self.generate_results(self.examples)
+ var = [location for rsync_out, name, version, arch, release, location in self.examples]
+ for i in range(len(results)):
+ self.assertEqual(results[i]["name"], var[i])
if __name__ == "__main__":
unittest.main()