Ignore:
Timestamp:
May 19, 2010 2:02:29 PM (14 years ago)
Author:
mylan
Message:

Added TestWidgetEditPresence? tests for presence of columns and buttons in edit mode of the widget

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.referencedatagridfield/branches/plone4/quintagroup/referencedatagridfield/tests/testWidget.py

    r2345 r2346  
    8484         
    8585 
     86class TestWidgetEditPresence(FunctionalTestCase): 
     87    """ Test presence of columns and button 
     88        in edit mode of ReferenceDataGridWidget. 
     89    """ 
     90 
     91    def afterSetUp(self): 
     92        self.loginAsPortalOwner() 
     93        # Prepare test data 
     94        self.createDemo() 
     95        demo = self.portal.demo 
     96        data = [{"link": "http://google.com"}] 
     97        demo.edit(demo_rdgf=data) 
     98        # Prepare html for test edit form 
     99        edit_path = "/" + demo.absolute_url(1) + "/edit" 
     100        basic_auth = ':'.join((portal_owner,default_password)) 
     101        self.html = self.publish(edit_path, basic_auth).getBody() 
     102 
     103    def test_columnsPresence(self): 
     104        # Get ReferenceDataGridField field inputs without hidden template row for add new data 
     105        reinput = re.compile("<input\s+([^>]*?name=\"demo_rdgf\.(.*?):records\"[^>]*?)>", re.I|re.S) 
     106        inputs = dict([(v,k) for k,v in reinput.findall(self.html) if not "demo_rdgf_new" in k]) 
     107        # Title and Link columns is visible 
     108        self.assertEqual('type="text"' in inputs["title"], True) 
     109        self.assertEqual('type="text"' in inputs["link"], True) 
     110        # UID column is hidden 
     111        self.assertEqual('type="hidden"' in inputs["uid"], True) 
     112 
     113    def test_addButtonPresence(self): 
     114        # Button for adding reference also must present 
     115        rebutt = re.compile("<input\s+[^>]*type=\"button\"\s*[^>]*>", re.I|re.S) 
     116        buttons = filter(lambda k:not "_new" in k, rebutt.findall(self.html)) 
     117        # Add... button must present 
     118        self.assertEqual('value="Add..."' in buttons[0], True) 
     119 
     120 
    86121def test_suite(): 
    87122    return unittest.TestSuite([ 
    88123        unittest.makeSuite(TestWidgetView), 
    89         #unittest.makeSuite(TestWidgetEdit), 
     124        unittest.makeSuite(TestWidgetEditPresence), 
    90125        ]) 
Note: See TracChangeset for help on using the changeset viewer.