Show
Ignore:
Timestamp:
06/25/09 13:17:49 (9 months ago)
Author:
JensDiemer
Message:
  • bugfix in pylucid_test_data.create_design()
  • add colorscheme arg in Design test
  • auto code cleanup
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/tests/test_Design.py

    r2043 r2068  
    2222    def __init__(self, *args, **kwargs): 
    2323        super(DesignTest, self).__init__(*args, **kwargs) 
    24          
     24 
    2525        self.test_css = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH) 
    2626        self.test_js = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_JS_FILEPATH) 
    2727 
    28     def _assert_headfiles(self, test_css_url, test_js_url): 
     28    def _assert_headfiles(self, colorscheme, test_css_url, test_js_url): 
    2929        """ 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 
    3333        # Test urls in the page content 
    3434        response = self.client.get("/") 
     
    3737                '1-rootpage content', # PageContent 
    3838                '<title>1-rootpage title', 
    39                  
     39 
    4040                # Design head file links: 
    4141                CSS_LINK % test_css_url, 
     
    4646            ), 
    4747        ) 
    48          
     48 
    4949    def test_cached(self): 
    5050        """ 
    5151        Test the stylesheet link, if the css file was cached into the filesystem. 
    52         """        
     52        """ 
     53        colorscheme = None 
     54 
    5355        # Create the cache file, if not exist 
    5456        for headfile in (self.test_css, self.test_js): 
    55             cachepath = headfile.get_cachepath() 
     57            cachepath = headfile.get_cachepath(colorscheme) 
    5658            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() 
    5862                headfile.save() # The save method should create the cache file 
    5963            # Check if file exist 
    60             self.failUnless(os.path.isfile(cachepath), "Can't create cache file???") 
     64            self.failUnless(os.path.isfile(cachepath), "Cache file %r doesn't not exist?!?!" % cachepath) 
    6165 
    6266        # Test get_absolute_url() and head links in reponse content 
    63         self._assert_headfiles( 
     67        self._assert_headfiles(colorscheme, 
    6468            "/media/PyLucid/headfile_cache/unittest/test.css", 
    6569            "/media/PyLucid/headfile_cache/unittest/test.js" 
    66         )             
     70        ) 
    6771 
    6872 
     
    7175        Test the stylesheet link, if the css file was *not* cached into the filesystem. 
    7276        """ 
     77        colorscheme = None 
     78 
    7379        # remove style cache file, if exist 
    7480        for headfile in (self.test_css, self.test_js): 
    75             cachepath = headfile.get_cachepath() 
     81            cachepath = headfile.get_cachepath(colorscheme) 
    7682            if os.path.isfile(cachepath): 
    7783                os.remove(cachepath) 
     
    7985 
    8086        # Test get_absolute_url() and head links in reponse content 
    81         self._assert_headfiles( 
     87        self._assert_headfiles(colorscheme, 
    8288            "/headfile/unittest/test.css", 
    8389            "/headfile/unittest/test.js"