Show
Ignore:
Timestamp:
03/27/08 16:59:44 (8 months ago)
Author:
JensDiemer
Message:

add a experimental new cache middleware
-merge pagestats into cache middleware
-add unitest for the cache
-move setup_debug() from the views into the common middleware
-update other tests

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/tests/__init__.py

    r1507 r1510  
    225225            is_list2 = pprint.pformat(is_list) 
    226226            should_be_list2 = pprint.pformat(should_be_list) 
     227            print "\nThe two lists are not the same:" 
    227228            for line in make_diff(should_be_list2, is_list2): 
    228229                print line 
     
    313314 
    314315    # _________________________________________________________________________ 
    315     # common tests: 
     316    # link snapshot: 
     317 
    316318    def link_snapshot_test(self, snapshot): 
    317319        """ 
     
    330332 
    331333        self.assertLists(is_links, should_be_links, sort=False) 
     334 
     335    def create_link_snapshot(self, print_result=True): 
     336        """ 
     337        Build a a reference snapshot for a unittest. 
     338        Display it via pprint and returned it, too. 
     339        Usefull for copy&paste the output into this source file :) 
     340        """ 
     341        if print_result: 
     342            print "Build a snapshot for the unittest compare:" 
     343            print "-"*79 
     344        data = {} 
     345        for page in Page.objects.all(): 
     346            url = page.get_absolute_url() 
     347 
     348            response = self.client.get(url) 
     349            self.failUnlessEqual(response.status_code, 200) 
     350 
     351            content = response.content.strip() 
     352            links = self.get_links(content) 
     353 
     354            data[url] = links 
     355 
     356        if print_result: 
     357            pprint.pprint(data) 
     358            print "-"*79 
     359        return data 
    332360 
    333361 
     
    391419 
    392420 
    393 def create_template(content): 
     421def create_template(**kwargs): 
    394422    """ 
    395423    Delete all existing templates, create a new one and return the instance. 
     
    397425    Template.objects.all().delete() 
    398426 
    399     template = Template(content = content) 
     427    template = Template(**kwargs) 
    400428    template.save() 
    401429    return template 
     
    421449    default_template = Template.objects.all()[0] 
    422450    default_style = Style.objects.all()[0] 
    423     default_markup = 0 # html withdout TinyMCE 
     451    default_markup = 0 # html without TinyMCE 
    424452 
    425453    page = Page( 
    426454        name             = data.get("name", "New Page"), 
    427455        shortcut         = data.get("shortcut", None), 
     456        content          = data.get("content", "TestPageContent"), 
    428457        template         = data.get("template", default_template), 
    429458        style            = data.get("style", default_style),