Changeset 155
- Timestamp:
- 12/01/06 17:15:45 (2 years ago)
- Files:
-
- trunk/tests/unit/_helper_cheesecake.py (modified) (3 diffs)
- trunk/tests/unit/test_index_installability.py (modified) (4 diffs)
- trunk/tests/unit/test_index_unittests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tests/unit/_helper_cheesecake.py
r97 r155 1 1 2 2 import os 3 import shutil 4 5 from mock import Mock 3 6 4 7 if 'set' not in dir(__builtins__): … … 6 9 7 10 DATA_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../data/')) 11 NOSE_PACKAGE_URL = "http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz" 8 12 9 13 class Glutton(object): … … 26 30 for filename in files: 27 31 create_empty_file(os.path.join(directory, filename)) 32 33 def dump_str_to_file(string, filename): 34 fd = file(filename, 'w') 35 fd.write(string) 36 fd.close() 37 38 def mocked_urlretrieve(url, filename): 39 if url == NOSE_PACKAGE_URL: 40 shutil.copy(os.path.join(DATA_PATH, "nose-0.8.3.tar.gz"), filename) 41 headers = Mock({'gettype': 'application/x-gzip'}) 42 else: 43 response_content = '''<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 44 <html><head> 45 <title>404 Not Found</title> 46 </head><body> 47 <h1>Not Found</h1> 48 <p>The requested URL was not found on this server.</p> 49 </body></html> 50 ''' 51 dump_str_to_file(response_content, filename) 52 headers = Mock({'gettype': 'text/html'}) 53 54 return filename, headers trunk/tests/unit/test_index_installability.py
r80 r155 2 2 3 3 import _path_cheesecake 4 from _helper_cheesecake import DATA_PATH 4 from _helper_cheesecake import DATA_PATH, NOSE_PACKAGE_URL 5 from _helper_cheesecake import dump_str_to_file 6 from _helper_cheesecake import mocked_urlretrieve 5 7 8 import cheesecake.cheesecake_index as cheesecake_index 6 9 from cheesecake.cheesecake_index import Cheesecake 7 10 from cheesecake.cheesecake_index import IndexPyPIDownload … … 17 20 def setUp(self): 18 21 self.cheesecake = None 22 self.nose_file_path = os.path.join(DATA_PATH, "nose-0.8.3.tar.gz") 19 23 20 24 def tearDown(self): … … 24 28 25 29 def test_index_installability_local_path(self): 26 self.cheesecake = Cheesecake(path= os.path.join(DATA_PATH, "nose-0.8.3.tar.gz"))30 self.cheesecake = Cheesecake(path=self.nose_file_path) 27 31 28 32 index = self.cheesecake.index["INSTALLABILITY"] … … 35 39 36 40 def test_index_installability_url_download(self): 37 self.cheesecake = Cheesecake(url="http://www.agilistas.org/cheesecake/nose-0.8.3.tar.gz") 41 # Mock a successful file download. 42 cheesecake_index.urlretrieve = mocked_urlretrieve 43 44 self.cheesecake = Cheesecake(url=NOSE_PACKAGE_URL) 38 45 39 46 index = self.cheesecake.index["INSTALLABILITY"] trunk/tests/unit/test_index_unittests.py
r89 r155 6 6 7 7 import _path_cheesecake 8 from _helper_cheesecake import dump_str_to_file 8 9 9 10 from cheesecake.cheesecake_index import IndexUnitTests 10 11 from cheesecake import logger 11 12 13 def dump_str_to_file(string, filename):14 fd = file(filename, 'w')15 fd.write(string)16 fd.close()17 12 18 13
