Changeset 2046

Show
Ignore:
Timestamp:
06/18/09 11:44:46 (9 months ago)
Author:
JensDiemer
Message:

add two ajax tests.

Files:
1 modified

Legend:

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

    r2043 r2046  
    1818 
    1919EDIT_PAGE_URL = "/?page_admin=inline_edit" 
     20PREVIEW_URL = "/?page_admin=preview" 
    2021 
    2122class EditPageTest(basetest.BaseUnittest): 
     
    3132         
    3233    def assertCanEdit(self, response): 
     34        """ assert that the response is the edit page form """ 
    3335        self.failUnlessEqual(response.status_code, 200) 
    3436        self.assertResponse(response, 
     
    3638                '1-rootpage content', # PageContent 
    3739                '<title>1-rootpage title', 
     40                # Some form strings: 
     41                'input type="submit" name="save" value="save"', 
     42                'form action="/?page_admin=inline_edit"', 
     43                'textarea id="id_content"', 
    3844            ), 
    3945            must_not_contain=( 
     
    97103        ) 
    98104 
     105    def test_ajax_form(self): 
     106        """ Test AJAX request of the edit page form """ 
     107        self.login(usertype="superuser") 
     108        response = self.client.get(EDIT_PAGE_URL, HTTP_X_REQUESTED_WITH='XMLHttpRequest') 
     109        self.failUnlessEqual(response.status_code, 200) 
     110        self.assertResponse(response, 
     111            must_contain=( 
     112                '1-rootpage content', # PageContent 
     113                # addition javascript from {% extrahead %} block: 
     114                '<!-- extrahead from .../apps/pylucid/defaulttags/extraheadBlock.py',  
     115                # Some form strings: 
     116                'input type="submit" name="save" value="save"', 
     117                'form action="/?page_admin=inline_edit"', 
     118                'textarea id="id_content"', 
     119            ), 
     120            must_not_contain=( 
     121                '<title>1-rootpage title', "<body", "<head>", # <- not a complete page 
     122                "Traceback", 'Permission denied', 
     123            ), 
     124        ) 
     125     
     126    def test_ajax_preview(self): 
     127        """ Test ajax edit page preview """ 
     128        self.login(usertype="superuser")        
     129        response = self.client.post(PREVIEW_URL, 
     130            {"content": "==headline"}, 
     131            HTTP_X_REQUESTED_WITH='XMLHttpRequest' 
     132        ) 
     133        self.failUnlessEqual(response.status_code, 200) 
     134        self.failUnlessEqual("<h2>headline</h2>\n", response.content) 
    99135 
    100136