Conjunto de mudanças 6484 no repositório publico


Ignorar:
Timestamp:
13/06/2012 15:55:27 (9 anos atrás)
Autor:
mazza
Mensagem:

testes ajustados

Localização:
PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/tests
Arquivos:
2 editados

Legenda:

Não Modificado
Adicionado
Removido
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/tests/testintegration.py

    r6471 r6484  
    66from plone.testing.z2 import Browser
    77from zExceptions import NotFound
     8from plone.app.testing import login, SITE_OWNER_NAME, SITE_OWNER_PASSWORD
    89
    910from il.portalinterlegis.browser.boxes import BoxManager
     
    1617
    1718    layer = IL_PORTALINTERLEGIS_INTEGRATION_TESTING
     19
    1820    def setUp(self):
    1921        self.app = self.layer['app']
     
    2123        self.qi_tool = getToolByName(self.portal, 'portal_quickinstaller')
    2224
    23     def browser(self, path=None):
     25    def new_browser(self, path=None, as_admin=False):
    2426        browser = Browser(self.app)
    2527        browser.handleErrors = False
     28        if as_admin:
     29            browser.open(self.url("login_form"))
     30            browser.getControl(name='__ac_name').value = SITE_OWNER_NAME
     31            browser.getControl(name='__ac_password').value = SITE_OWNER_PASSWORD
     32            browser.getControl(name='submit').click()
    2633        browser.open(self.url(path))
    2734        return browser
     
    4754
    4855    def test_tabs_na_home(self):
    49         browser = self.browser()
     56        browser = self.new_browser()
    5057        dom = self.dom(browser)
    5158        self.assertEqual([u'O Interlegis',
     
    7683
    7784        def use_box_form(title, subtitle, text, num):
    78             browser = self.browser(boxmanager._box_name_for_url(num))
     85            browser = self.new_browser(boxmanager._box_name_for_url(num), as_admin=True)
    7986            browser.getControl(name='form.widgets.title').value = title
    8087            browser.getControl(name='form.widgets.subtitle').value = subtitle
     
    9198    def test_box_forms_numbers_begin_from_1_not_zero(self):
    9299        with self.assertRaises(NotFound):
    93             browser = self.browser(BoxManager(ISimpleBox)._box_name_for_url(0))
     100            browser = self.new_browser(BoxManager(ISimpleBox)._box_name_for_url(0), as_admin=True)
    94101
    95102    def test_box_forms_are_limited(self):
    96103        with self.assertRaises(NotFound):
    97             browser = self.browser(BoxManager(ISimpleBox)._box_name_for_url(1000000))
     104            browser = self.new_browser(BoxManager(ISimpleBox)._box_name_for_url(1000000), as_admin=True)
    98105
    99106    def test_box_form_cannot_be_created_after_initialization(self):
    100107        BoxManager(ISimpleBox).build_form(99) # try to build a box form in an arbitrary moment
    101108        with self.assertRaises(NotFound):
    102             browser = self.browser(BoxManager(ISimpleBox)._box_name_for_url(99))
     109            browser = self.new_browser(BoxManager(ISimpleBox)._box_name_for_url(99), as_admin=True)
    103110
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/tests/testunitboxes.py

    r6474 r6484  
    3939    def test_row(self):
    4040        context = object()
    41         with patch.object(BoxManager, 'html') as mock:
     41        with patch.object(BoxManager, 'html') as mock_html:
     42            with patch.object(BoxManager, '_box_key') as mock_box_key:
    4243
    43             @return_values(mock, ['\n      %s' % s for s in ['AAA', 'BBB', 'CCC', 'DDD']])
    44             def side_effect(c, n):
    45                 self.assertIs(context, c)
     44                @return_values(mock_html, ['\n      %s' % s for s in ['AAA', 'BBB', 'CCC', 'DDD']])
     45                def side_effect(c, n):
     46                    self.assertIs(context, c)
    4647
    47             self.assertEqual('''
     48                from itertools import count
     49                numbers = count(1)
     50                @return_values(mock_box_key, [1, 2, 3, 4])
     51                def side_effect(n):
     52                    self.assertIs(numbers.next(), n)
     53
     54                self.assertEqual('''
    4855  <div class="dt-row">
    49     <div class="dt-cell dt-position-0 dt-width-1">
     56    <div id="1" class=" dt-cell dt-position-0 dt-width-1">
    5057      AAA
    5158    </div>
    52     <div class="dt-cell dt-position-1 dt-width-2">
     59    <div id="2" class=" dt-cell dt-position-1 dt-width-2">
    5360      BBB
    5461    </div>
    55     <div class="dt-cell dt-position-3 dt-width-3">
     62    <div id="3" class=" dt-cell dt-position-3 dt-width-3">
    5663      CCC
    5764    </div>
    58     <div class="dt-cell dt-position-6 dt-width-1">
     65    <div id="4" class=" dt-cell dt-position-6 dt-width-1">
    5966      DDD
    6067    </div>
    6168  </div>
    62 ''', row_html(context, [(1, _, _), (2, _, _), (3, _, _), (1, _, _)] ))
     69''', row_html(context, [(1, _, 1), (2, _, 2), (3, _, 3), (1, _, 4)] ))
    6370
    6471
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.