Exemple #1
0
    def javascript_url_base(self, debug=True):
        """ Base method to test javascript_url method
        """
        # Context
        mock_context = self.mocker.mock()
        self.expect(
            mock_context.absolute_url()).result('http://url.com').count(
                0, None)

        # Request
        mock_request = self.mocker.mock()

        # Register Url Tool
        mock_prortal_url = self.mocker.mock()
        self.expect(mock_prortal_url()).result('http://url.com')

        self.mock_tool(mock_prortal_url, "portal_url")

        # Register Javascript Tool
        mock_javascript = self.mocker.mock()
        self.expect(mock_javascript.getDebugMode()).result(debug)

        self.mock_tool(mock_javascript, "portal_javascripts")

        self.replay()

        mock_addForm = AddForm(mock_context, mock_request)
        return mock_addForm.javascript_url()
    def javascript_url_base(self, debug=True):
        """ Base method to test javascript_url method
        """
        # Context
        mock_context = self.mocker.mock()
        self.expect(
            mock_context.absolute_url()).result(
                'http://url.com').count(0, None)

        # Request
        mock_request = self.mocker.mock()

        # Register Url Tool
        mock_prortal_url = self.mocker.mock()
        self.expect(
            mock_prortal_url()).result('http://url.com')

        self.mock_tool(mock_prortal_url, "portal_url")

        # Register Javascript Tool
        mock_javascript = self.mocker.mock()
        self.expect(
            mock_javascript.getDebugMode()).result(debug)

        self.mock_tool(mock_javascript, "portal_javascripts")

        self.replay()

        mock_addForm = AddForm(mock_context, mock_request)
        return mock_addForm.javascript_url()
Exemple #3
0
    def replace_interactive_user_base(self, principal, context):
        """ Base method to test replace_interactive_user method
        """

        mock_context = context

        # Request
        mock_request = self.mocker.mock()

        self.replay()

        mock_addForm = AddForm(mock_context, mock_request)

        return mock_addForm.replace_interactive_user(principal)
    def replace_interactive_user_base(self, principal, context):
        """ Base method to test replace_interactive_user method
        """

        mock_context = context

        # Request
        mock_request = self.mocker.mock()

        self.replay()

        mock_addForm = AddForm(mock_context, mock_request)

        return mock_addForm.replace_interactive_user(principal)
Exemple #5
0
    def test_load_request_parameters(self):
        """ Test load_request_parameters-method
        """
        # Context
        mock_context = self.mocker.mock()
        self.expect(
            mock_context.absolute_url()).result('http://url.com').count(
                0, None)

        # Sort_on-Object
        mock_sort_on = self.mocker.mock()
        self.expect(mock_sort_on.startswith(ANY)).result(True).count(0, None)
        self.expect(mock_sort_on.split(ANY)).result(['header-',
                                                     'sortme']).count(0, None)

        # Request
        mock_request = self.mocker.mock()
        self.expect(mock_request.get('pagenumber',
                                     ANY)).result(3).count(0, None)
        self.expect(mock_request.get('sort',
                                     ANY)).result(mock_sort_on).count(0, None)
        self.expect(mock_request.get('searchable_text')).result(
            'my text to search').count(0, None)
        self.expect(mock_request.get('dir', ANY)).result('ASC').count(0, None)
        self.expect(
            mock_request.__mocker_act__(
                "contains",
                ('searchable_text', ))).result(True).count(0, None)
        self.expect(mock_request.request).result('http://url.com').count(
            0, None)
        self.expect(
            mock_request.searchable_text).result('http://url.com').count(
                0, None)

        # AddForm Obj
        mock_addForm = self.mocker.patch(AddForm(mock_context, mock_request))
        self.expect(mock_addForm.pagesize).result(5).count(0, None)
        self.expect(mock_addForm.sort_on).result(mock_sort_on).count(0, None)
        self.expect(mock_addForm.sort_reverse).result('reverse').count(0, None)

        self.replay()

        mock_addForm.load_request_parameters()

        # Check attributes
        self.assertTrue(3 == mock_addForm.batching_current_page)
        self.assertTrue(
            mock_addForm.pagenumber == mock_addForm.batching_current_page)
        self.assertTrue(5 == mock_addForm.batching_pagesize)
        self.assertTrue('http://url.com' == mock_addForm.url)
        self.assertTrue(3 == mock_addForm.batching_current_page)
        self.assertTrue('my text to search' == mock_addForm.filter_text)
        self.assertTrue('asc' == mock_addForm.sort_order)