Changeset 22
- Timestamp:
- 05/27/06 16:16:09 (7 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (2 diffs)
- branches/mk/tests/test_index_unpack.py (modified) (1 diff)
- branches/mk/tests/test_index_url_download.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r21 r22 132 132 self.url = url 133 133 self.package_path = path 134 134 135 if not self.name and not self.url and not self.package_path: 135 136 self.raise_exception("No package name, URL or path specified ... exiting") 136 self.sandbox = sandbox or default_temp_directory 137 138 self.sandbox = sandbox or tempfile.mkdtemp(prefix='cheesecake') 137 139 if not os.path.isdir(self.sandbox): 138 140 os.mkdir(self.sandbox) 141 139 142 self.config = config 140 143 self.verbose = verbose … … 977 980 default="", help="package path on local file system") 978 981 parser.add_option("-s", "--sandbox", dest="sandbox", 979 default=default_temp_directory, 980 help="directory where package will be unpacked (default=%s)" % default_temp_directory) 982 default=None, 983 help="directory where package will be unpacked "\ 984 "(default is to use random directory inside %s)" % tempfile.gettempdir()) 981 985 parser.add_option("-c", "--config", dest="config", 982 986 default=None, branches/mk/tests/test_index_unpack.py
r21 r22 19 19 os.unlink(self.cheesecake.logfile) 20 20 21 def test_index_unpack_valid_tar_gz(self):22 self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz"))21 def _run_valid(self, package_file, message): 22 self.cheesecake = Cheesecake(path=os.path.join(datadir, package_file)) 23 23 index = self.cheesecake.index_unpack() 24 24 assert index.name == "index_unpack" 25 25 assert index.value == self.cheesecake.INDEX_UNPACK 26 assert index.details == "package untar-ed successfully" 26 assert index.details == message 27 28 def test_index_unpack_valid_tar_gz(self): 29 self._run_valid("package1.tar.gz", "package untar-ed successfully") 27 30 28 31 def test_index_unpack_valid_tgz(self): 29 self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tgz")) 30 index = self.cheesecake.index_unpack() 31 assert index.name == "index_unpack" 32 assert index.value == self.cheesecake.INDEX_UNPACK 33 assert index.details == "package untar-ed successfully" 32 self._run_valid("package1.tgz", "package untar-ed successfully") 34 33 35 34 def test_index_unpack_valid_zip(self): 36 self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.zip")) 37 index = self.cheesecake.index_unpack() 38 assert index.name == "index_unpack" 39 assert index.value == self.cheesecake.INDEX_UNPACK 40 assert index.details == "package unzipped successfully" 35 self._run_valid("package1.zip", "package unzipped successfully") 41 36 42 def test_index_unpack_invalid_tar_gz(self):37 def _run_invalid(self, package_file, message): 43 38 try: 44 self.cheesecake = Cheesecake(path=os.path.join(datadir, "invalid_package.tar.gz")) 39 self.cheesecake = Cheesecake(path=os.path.join(datadir, package_file), 40 sandbox=default_temp_directory) 45 41 assert 0 # This statement should not be reached 46 42 except CheesecakeError, e: 47 msg = "Could not read tar file %s ... exiting\n" % \ 48 os.path.join(default_temp_directory, 'invalid_package.tar.gz') 43 msg = message % os.path.join(default_temp_directory, package_file) 49 44 msg += pad_msg("CHEESECAKE INDEX", 0) 50 45 assert str(e) == msg 51 46 47 def test_index_unpack_invalid_tar_gz(self): 48 self._run_invalid("invalid_package.tar.gz", 49 "Could not read tar file %s ... exiting\n") 50 52 51 def test_index_unpack_invalid_tgz(self): 53 try: 54 self.cheesecake = Cheesecake(path=os.path.join(datadir, "invalid_package.tgz")) 55 assert 0 # This statement should not be reached 56 except CheesecakeError, e: 57 msg = "Could not read tar file %s ... exiting\n" % \ 58 os.path.join(default_temp_directory, 'invalid_package.tgz') 59 msg += pad_msg("CHEESECAKE INDEX", 0) 60 assert str(e) == msg 52 self._run_invalid("invalid_package.tgz", 53 "Could not read tar file %s ... exiting\n") 61 54 62 55 def test_index_unpack_invalid_zip(self): 63 try: 64 self.cheesecake = Cheesecake(path=os.path.join(datadir, "invalid_package.zip")) 65 assert 0 # This statement should not be reached 66 except CheesecakeError, e: 67 msg = "Error unzipping file %s ... exiting\n" % \ 68 os.path.join(default_temp_directory, 'invalid_package.zip') 69 msg += pad_msg("CHEESECAKE INDEX", 0) 70 assert str(e) == msg 56 self._run_invalid("invalid_package.zip", 57 "Error unzipping file %s ... exiting\n") branches/mk/tests/test_index_url_download.py
r21 r22 22 22 23 23 def test_index_url_download_valid_url(self): 24 def test_fun(): 25 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 24 datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) 26 25 27 urls = [28 "http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz",29 "file://%s" % os.path.join(datadir, "nose-0.8.3.tar.gz")30 ]26 urls = [ 27 "http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz", 28 "file://%s" % os.path.join(datadir, "nose-0.8.3.tar.gz") 29 ] 31 30 32 for url in urls: 31 for url in urls: 32 def test_fun(): 33 33 try: 34 34 self.cheesecake = Cheesecake(url=url) … … 45 45 assert str(e) == msg 46 46 47 self._run_it(test_fun)47 self._run_it(test_fun) 48 48 49 49 def test_index_url_download_invalid_url(self): 50 50 def test_fun(): 51 51 try: 52 self.cheesecake = Cheesecake(url="http://www.agilistas.org/cheesecake/not_there.tar.gz") 52 self.cheesecake = Cheesecake(url="http://www.agilistas.org/cheesecake/not_there.tar.gz", 53 sandbox=default_temp_directory) 53 54 assert 0 # This statement should not be reached 54 55 except CheesecakeError, e:
