Changeset 23

Show
Ignore:
Timestamp:
07/13/06 02:19:08 (2 years ago)
Author:
tim
Message:

making the twill script more general and capable

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jobs/instance_tester.py

    r11 r23  
    2121browser.go(instance_url) 
    2222 
     23def switch_to_theme(name): 
     24    browser.go(theme_switch_page % name) 
     25    if browser.get_url().find("/admin/themes") < 0: 
     26        print "are we not logged in?" 
     27        login() 
     28        browser.go(theme_switch_page % name) 
     29        if browser.get_url().find("/admin/themes") < 0: 
     30            print "hmm, something else must be wrong" 
     31 
    2332def login(): 
    2433    def create_account(): 
     
    4251    browser.submit("login") 
    4352 
    44 login() 
     53def test_all_themes(): 
     54    login() 
     55    browser.go(themes_page) 
     56    print browser.get_code() 
     57    browser.go(themes_page) 
    4558 
    46 browser.go(themes_page) 
    47 print browser.get_code() 
     59    # The active theme when the program starts is not found 
     60    # using this method for gathering theme names 
     61    theme_names = [] 
    4862 
    49 print browser.get_code() 
     63    for fragment in theme_locate_regexp.findall(browser.get_html()): 
     64        theme_name = fragment.split("=")[2].replace('"', '') 
     65        theme_names.append(theme_name) 
    5066 
    51 browser.go(themes_page) 
     67    print "we have %d themes to test" % len(theme_names) 
    5268 
    53 # The active theme when the program starts is not found 
    54 # using this method for gathering theme names 
    55 theme_names = [] 
     69    for name in theme_names: 
     70        print "testing for %s" % name 
     71        switch_to_theme(name) 
     72     
     73        browser.go(instance_url) 
     74        if browser.get_code() == 200: 
     75            print "seems to work" 
     76            # match = theme_check_regexp.search(browser.get_html()) 
     77            #         if not match: 
     78            #             print "no good.... no theme sidebar found" 
     79            #         else: 
     80            #             found_name = match.group(0).split('=')[1] 
     81            #             print "we found %s" % found_name 
     82        elif browser.get_code() == 500: 
     83            print "%s is broken" % name 
     84        else: 
     85            print "browser code is %d" % browser.get_code() 
    5686 
    57 for fragment in theme_locate_regexp.findall(browser.get_html()): 
    58     theme_name = fragment.split("=")[2].replace('"', '') 
    59     theme_names.append(theme_name) 
     87    print "now we are done" 
    6088 
    61 print "we have %d themes to test" % len(theme_names) 
    62  
    63 for name in theme_names: 
    64     print "testing for %s" % name 
    65     browser.go(theme_switch_page % name) 
    66      
    67     browser.go(instance_url) 
    68     if browser.get_code() == 200: 
    69         print "seems to work" 
    70         # match = theme_check_regexp.search(browser.get_html()) 
    71         #         if not match: 
    72         #             print "no good.... no theme sidebar found" 
    73         #         else: 
    74         #             found_name = match.group(0).split('=')[1] 
    75         #             print "we found %s" % found_name 
    76     elif browser.get_code() == 500: 
    77         print "%s is broken" % name 
    78     else: 
    79         print "browser code is %d" % browser.get_code() 
    80  
    81 print "now we are done" 
     89if __name__ == "__main__": 
     90    switch_to_theme("peaks")