Changeset 2068 for branches/0.9/pylucid_project/tests/test_Design.py
- Timestamp:
- 06/25/09 13:17:49 (9 months ago)
- Files:
-
- 1 modified
-
branches/0.9/pylucid_project/tests/test_Design.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/tests/test_Design.py
r2043 r2068 22 22 def __init__(self, *args, **kwargs): 23 23 super(DesignTest, self).__init__(*args, **kwargs) 24 24 25 25 self.test_css = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH) 26 26 self.test_js = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_JS_FILEPATH) 27 27 28 def _assert_headfiles(self, test_css_url, test_js_url):28 def _assert_headfiles(self, colorscheme, test_css_url, test_js_url): 29 29 """ Test get_absolute_url() and head links in reponse content """ 30 self.failUnlessEqual(self.test_css.get_absolute_url( ), test_css_url)31 self.failUnlessEqual(self.test_js.get_absolute_url( ), test_js_url)32 30 self.failUnlessEqual(self.test_css.get_absolute_url(colorscheme), test_css_url) 31 self.failUnlessEqual(self.test_js.get_absolute_url(colorscheme), test_js_url) 32 33 33 # Test urls in the page content 34 34 response = self.client.get("/") … … 37 37 '1-rootpage content', # PageContent 38 38 '<title>1-rootpage title', 39 39 40 40 # Design head file links: 41 41 CSS_LINK % test_css_url, … … 46 46 ), 47 47 ) 48 48 49 49 def test_cached(self): 50 50 """ 51 51 Test the stylesheet link, if the css file was cached into the filesystem. 52 """ 52 """ 53 colorscheme = None 54 53 55 # Create the cache file, if not exist 54 56 for headfile in (self.test_css, self.test_js): 55 cachepath = headfile.get_cachepath( )57 cachepath = headfile.get_cachepath(colorscheme) 56 58 if not os.path.isfile(cachepath): 57 os.makedirs(os.path.dirname(cachepath)) # Cache dir doesn't exist? 59 cachedir = os.path.dirname(cachepath) 60 if not os.path.isdir(cachedir): 61 os.makedirs() 58 62 headfile.save() # The save method should create the cache file 59 63 # Check if file exist 60 self.failUnless(os.path.isfile(cachepath), "Ca n't create cache file???")64 self.failUnless(os.path.isfile(cachepath), "Cache file %r doesn't not exist?!?!" % cachepath) 61 65 62 66 # Test get_absolute_url() and head links in reponse content 63 self._assert_headfiles( 67 self._assert_headfiles(colorscheme, 64 68 "/media/PyLucid/headfile_cache/unittest/test.css", 65 69 "/media/PyLucid/headfile_cache/unittest/test.js" 66 ) 70 ) 67 71 68 72 … … 71 75 Test the stylesheet link, if the css file was *not* cached into the filesystem. 72 76 """ 77 colorscheme = None 78 73 79 # remove style cache file, if exist 74 80 for headfile in (self.test_css, self.test_js): 75 cachepath = headfile.get_cachepath( )81 cachepath = headfile.get_cachepath(colorscheme) 76 82 if os.path.isfile(cachepath): 77 83 os.remove(cachepath) … … 79 85 80 86 # Test get_absolute_url() and head links in reponse content 81 self._assert_headfiles( 87 self._assert_headfiles(colorscheme, 82 88 "/headfile/unittest/test.css", 83 89 "/headfile/unittest/test.js"