def setUp(self):
        MockTestCase.setUp(self)

        self.context = self.providing_stub(IWorkspace)
        self.expect(self.context.getPhysicalPath()).result(
            ['', 'path', 'to', 'workspace'])
        self.expect(self.context.getOwner(0).getId()).result('john.doe')

        self.response = self.stub()
        self.expect(self.response.getHeader(ANY))
        self.expect(self.response.setHeader(ANY, ANY))
        self.request = self.create_dummy(debug=True,
                                         response=self.response)

        self.builder = self.stub_interface(IBuilder)
        self.layout = WorkspaceLayout(
            self.context, self.request, self.builder)
        self.view = WorkspaceDetailsView(
            self.context, self.request, self.layout)

        portal_catalog = self.stub()
        self.mock_tool(portal_catalog, 'portal_catalog')
        self.brains = []
        self.expect(portal_catalog({'path': '/path/to/workspace',
                                    'portal_type': ['File'],
                                    'sort_on': 'created',
                                    'sort_order': 'reverse'})).call(
            lambda q: self.brains)

        acl_users = self.stub()
        self.mock_tool(acl_users, 'acl_users')
        self.expect(acl_users.getUserById('john.doe').getProperty(
                'fullname', 'john.doe')).result('John Doe')
    def setUp(self):
        MockTestCase.setUp(self)

        self.context = self.providing_stub(IWorkspace)
        self.expect(self.context.getPhysicalPath()).result(
            ['', 'path', 'to', 'workspace'])

        self.layout = self.stub_interface(ILaTeXLayout)
        self.expect(self.layout.use_package(ANY))

        self.view = self.stub_interface(ILaTeXView)

        def convert(*args, **kwargs):
            return getMultiAdapter(
                (self.context, self.request, self.layout),
                IHTML2LaTeXConverter).convert(*args, **kwargs)

        self.expect(self.view.convert).result(convert)

        self.response = self.stub()
        self.expect(self.response.getHeader(ANY))
        self.expect(self.response.setHeader(ANY, ANY))
        self.request = self.create_dummy(debug=True,
                                         response=self.response)
        self.expect(self.context.REQUEST).result(self.request)

        portal_catalog = self.stub()
        self.mock_tool(portal_catalog, 'portal_catalog')

        self.tasks = []
        def get_catalog_result(query):
            brains = []
            for obj in self.tasks:
                brains.append(self.create_dummy(getObject=lambda x=obj: x,
                                                **obj.__dict__))

            return brains

        self.expect(portal_catalog(
                {'path': '/path/to/workspace',
                 'portal_type': ['Task'],
                 'sort_on': 'end',
                 'sort_order': 'reverse'})).call(get_catalog_result)

        self.acl_users = self.stub()
        self.mock_tool(self.acl_users, 'acl_users')
        self._mock_user('john.doe', 'John Doe')
        self._mock_user('hugo.boss', 'Hugo Boss')
        self._mock_user('jane.doe', 'Jane Doe')

        self.translation_service = TranslationServiceStub(self.context)
        self.mock_tool(self.translation_service, 'translation_service')

        self.portal_properties = self.stub()
        self.mock_tool(self.portal_properties, 'portal_properties')
        self.expect(self.portal_properties.site_properties).result(
            self.create_dummy(localLongTimeFormat='%d.%m.%Y %H:%M',
                              localTimeFormat='%d.%m.%Y',
                              localTimeOnlyFormat='%H:%M'))
Beispiel #3
0
    def setUp(self):
        MockTestCase.setUp(self)

        self.urllib2 = self.mocker.replace('urllib2')
        # Let the urllib2 not do any requests at all while
        # testing. We do this by expecting any request call zero times.
        self.expect(self.urllib2.build_opener(ARGS, KWARGS)).count(0)
        self.expect(self.urllib2.Request(ARGS, KWARGS)).count(0)
Beispiel #4
0
    def setUp(self):
        MockTestCase.setUp(self)

        self.urllib2 = self.mocker.replace('urllib2')
        # Let the urllib2 not do any requests at all while
        # testing. We do this by expecting any request call zero times.
        self.expect(self.urllib2.build_opener(ARGS, KWARGS)).count(0)
        self.expect(self.urllib2.Request(ARGS, KWARGS)).count(0)
    def setUp(self):
        MockTestCase.setUp(self)
        self.config = self.stub_interface(IBridgeConfig)
        self.expect(self.config.get_bridge_ips()).result([
                '127.0.0.1', '127.0.0.2'])
        self.mock_utility(self.config, IBridgeConfig)

        self.valid_credentials = {'id': 'john.doe',
                                  'login': '******',
                                  'ip': '127.0.0.1',
                                  'extractor': 'bridge'}
Beispiel #6
0
    def setUp(self):
        MockTestCase.setUp(self)
        self.config = self.stub_interface(IBridgeConfig)
        self.expect(self.config.get_bridge_ips()).result(
            ['127.0.0.1', '127.0.0.2'])
        self.mock_utility(self.config, IBridgeConfig)

        self.valid_credentials = {
            'id': 'john.doe',
            'login': '******',
            'ip': '127.0.0.1',
            'extractor': 'bridge'
        }
    def setUp(self):
        MockTestCase.setUp(self)

        self.context = self.providing_stub(IWorkspace)
        self.expect(self.context.getPhysicalPath()).result(
            ['', 'path', 'to', 'workspace'])

        self.layout = self.stub_interface(ILaTeXLayout)
        self.expect(self.layout.use_package(ANY))

        self.view = self.stub_interface(ILaTeXView)

        def convert(*args, **kwargs):
            return getMultiAdapter(
                (self.context, self.request, self.layout),
                IHTML2LaTeXConverter).convert(*args, **kwargs)

        self.expect(self.view.convert).result(convert)

        self.response = self.stub()
        self.expect(self.response.getHeader(ANY))
        self.expect(self.response.setHeader(ANY, ANY))
        self.request = self.create_dummy(debug=True,
                                         response=self.response)

        portal_catalog = self.stub()
        self.mock_tool(portal_catalog, 'portal_catalog')

        self.meetings = []
        def get_catalog_result(query):
            brains = []
            for obj in self.meetings:
                brains.append(self.create_dummy(getObject=lambda: self.meetings.pop(0)))
            return brains

        self.expect(portal_catalog(
                {'path': '/path/to/workspace',
                 'portal_type': ['Meeting',
                                 'Poodle',
                                 'Event'],
                 'sort_on': 'start',
                 'sort_order': 'reverse'})).call(get_catalog_result)

        self.acl_users = self.stub()
        self.mock_tool(self.acl_users, 'acl_users')
        self._mock_user('john.doe', 'John Doe')
Beispiel #8
0
 def tearDown(self):
     MockTestCase.setUp(self)
     test_customizable_layout.TestCustomizableLayout.setUp(self)
Beispiel #9
0
 def setUp(self):
     test_customizable_layout.TestCustomizableLayout.setUp(
         self, context=self.create_dummy(getLanguage=lambda: "de-ch")
     )
     MockTestCase.setUp(self)