Changeset 3019 in products


Ignore:
Timestamp:
Nov 15, 2010 1:07:25 PM (13 years ago)
Author:
fenix
Message:

added tests for type by state view.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.analytics/trunk/quintagroup/analytics/tests.py

    r3017 r3019  
    278278        self.assertEqual(*map(lambda s:''.join(s.split()), 
    279279                              [chart_tag, self.view.getChart()])) 
     280 
     281class TestTypeByState(TestCase): 
     282    """Tests all type_by_state view methods.""" 
     283    layer = SetUpContent 
     284    states = ['private', 'published', 'pending'] 
     285 
     286    def afterSetUp(self): 
     287        self.view = queryMultiAdapter((self.portal, self.portal.REQUEST), 
     288                                 name="type_by_state") 
     289        self.pc = self.portal.portal_catalog 
     290 
     291    def test_getTypes(self): 
     292        """ Tests method that returns ordered list of types.""" 
     293        self.assert_(False not in map(lambda t1, t2:t1==t2, 
     294                                      ['Folder', 'Document', 'Event', 'Topic'], 
     295                                      self.view.getTypes())) 
     296 
     297    def test_getStates(self): 
     298        """ Tests method that returns ordered list of states.""" 
     299        self.assert_(False not in map(lambda s1, s2:s1==s2, 
     300                     ['private', 'published'], self.view.getStates())) 
     301 
     302    def test_getContent(self): 
     303        """ This test verifies method that returns list of numbers. 
     304            Each number is amount of specified content type objects 
     305            that owned  by particular user. 
     306        """ 
     307        # we need to login in to the site as Manager to be able to 
     308        # see catalog results 
     309        self.loginAsPortalOwner() 
     310 
     311        for state in self.states: 
     312            self.assert_(False not in \ 
     313            map(lambda i, j:i==j, [len(self.pc(portal_type=type_, 
     314                                               review_state=state)) 
     315                                   for type_ in self.view.getTypes()], 
     316                                  self.view.getContent(state))) 
     317 
     318    def test_getChart(self): 
     319        """ This test verifies creation of chart image tag.""" 
     320        chart_tag = """ <imgsrc="http://chart.apis.google.com/chart?chxt=y&amp; 
     321                        chds=0,159&amp;chd=t:156.0,145.0,145.0,0.0|3.0,1.0,0.0, 
     322                        3.0|0.0,0.0,0.0,0.0&amp;chxr=0,0,159&amp;chco=669933, 
     323                        cc9966,993300,ff6633,e8e4e3,a9a486,dcb57e,ffcc99,996633, 
     324                        333300,00ff00&amp;chl=Folder|Document|Event|Topic&amp; 
     325                        chbh=a,10,0&amp;chs=800x375&amp;cht=bvs&amp; 
     326                        chtt=Content+type+by+state&amp;chdl=private|published| 
     327                        No+workflow&amp;chdlp=b"/>""" 
     328 
     329        self.loginAsPortalOwner() 
     330        self.assertEqual(*map(lambda s:''.join(s.split()), 
     331                              [chart_tag, self.view.getChart()])) 
     332 
    280333def test_suite(): 
    281334    from unittest import TestSuite, makeSuite 
     
    307360    test_suite.addTest(makeSuite(TestOwnershipByType)) 
    308361    test_suite.addTest(makeSuite(TestOwnershipByState)) 
     362    test_suite.addTest(makeSuite(TestTypeByState)) 
    309363    return test_suite 
    310364 
Note: See TracChangeset for help on using the changeset viewer.