def test_protocol_read(self): request = TestRequest(form={'cmd': 'revcount'}) request.method = 'GET' protocol_read = zope.component.getMultiAdapter( (self.portal.workspace.test, request), name='protocol_read') result = protocol_read() self.assertEqual(result, '4')
def test_user_email_set(self): self.login('user1') context = self.portal request = TestRequest( form={ 'form.widgets.addresses': '[email protected]\[email protected]', 'form.buttons.apply': 1, }) form = UserEmailForm(context, request) result = form() self.assertEqual(self.email_manager.get_emails_for('user1'), [ u'*****@*****.**', u'*****@*****.**', ]) self.login('user2') context = self.portal request = TestRequest( form={ 'form.widgets.addresses': '[email protected]\[email protected]', 'form.buttons.apply': 1, }) form = UserEmailForm(context, request) result = form() self.assertEqual(self.email_manager.get_emails_for('user2'), [ u'*****@*****.**', ])
def build_wsgi_request(script, q, method='GET'): qs = '&'.join(['%s=%s' % (k, v) for k, v in q.iteritems()]) env = build_wsgi_env('workspace_view', qs) request = TestRequest(form=q) request.environ = env request.stdin = env['wsgi.input'] return request
def test_002_revision_and_path(self): request = TestRequest() page = browser.WorkspaceTraversePage(None, request) page.publishTraverse(request, '123456') page.publishTraverse(request, 'dir1') self.assertEqual(request.get('rev'), '123456') self.assertEqual(request.get('request_subpath'), ['dir1'])
def test_storage_protocol_legacy_get(self): self.workspace.storage = 'legacy_dummy_storage' # force request to GET request = TestRequest(form={'cmd': 'revcount'}) request.method = 'GET' # storage adapter should now return. pa = StorageProtocolAdapter(self.workspace, request) result = pa() self.assertEqual(result, '4') # no events fired for GET requets. self.assertEqual(self.subscribers, [])
def test_render_field(self): self.settings.wf_change_recipient = u'*****@*****.**' request = TestRequest() form = SettingsEditForm(self.layer['portal'], request) form.update() result = form.render() self.assertIn('*****@*****.**', result)
def test_0000_import_form_render(self): context = self.portal request = TestRequest() f = form.CitationImportForm(context, request) # force this instance as a wrapped form to not render cruft. zope.interface.directlyProvides(f, IWrappedForm) f.update() result = f.render() self.assertTrue('test_json' in result)
def test_0101_import_form_import_default(self): context = self.folder request = TestRequest( form={ 'form.widgets.import_method': 'test_json', 'form.widgets.identifier': u'urn:example:json:test.cite.2', 'form.buttons.import': 1, }) f = form.CitationImportForm(context, request) f.update() self.assertFalse('testj2' in self.folder)
def test_0100_import_form_all_specified(self): context = self.portal request = TestRequest( form={ 'form.widgets.import_method': 'test_json', 'form.widgets.identifier': u'urn:example:json:test.cite.1', 'form.widgets.import_here': [u'true'], 'form.buttons.import': 1, }) f = form.CitationImportForm(context, request) f.update() self.assertEqual(self.portal.testj1.title, u'Test Citation Title')
def test_0201_protocol_push(self): utility = MercurialStorageUtility() req = TestRequest() req.base = "http://127.0.0.1" req.method = "POST" req.environ["QUERY_STRING"] = "cmd=unbundle" req.environ["REMOTE_ADDR"] = "127.0.0.1" req.environ["SCRIPT_NAME"] = "script" req.stdin = StringIO() result = utility.protocol(self.workspace, req) self.assertFalse(result.event is None)
def test_0200_protocol_default(self): utility = MercurialStorageUtility() req = TestRequest() req.base = "http://127.0.0.1" req.method = "GET" req.environ["QUERY_STRING"] = "cmd=capabilities" req.environ["REMOTE_ADDR"] = "127.0.0.1" req.environ["SCRIPT_NAME"] = "script" req.stdin = StringIO() result = utility.protocol(self.workspace, req) self.assertTrue(result.event is None)
def test_edit_field(self): request = TestRequest( form={ 'form.widgets.wf_change_recipient': '*****@*****.**', 'form.widgets.wf_send_email': 'selected', 'form.widgets.subject_template': 'subject', 'form.widgets.message_template': 'message', 'form.buttons.apply': 1, }) form = SettingsEditForm(self.layer['portal'], request) form.update() self.assertEqual(self.settings.wf_change_recipient, '*****@*****.**') self.assertTrue(self.settings.wf_send_email)
def test_0102_import_form_import_default(self): registry = zope.component.queryUtility(IRegistry) settings = registry.forInterface(ICitationSettings, prefix="pmr2.citations.settings", check=False) settings.default_path = '/plone/Members/test_user_1_' context = self.folder request = TestRequest( form={ 'form.widgets.import_method': 'test_json', 'form.widgets.identifier': u'urn:example:json:test.cite.2', 'form.buttons.import': 1, }) f = form.CitationImportForm(context, request) f.update() self.assertEqual(self.folder.testj2.title, u'Number 2 Test')
def test_0100_import_form(self): registry = zope.component.queryUtility(IRegistry) settings = registry.forInterface(ICitationSettings, prefix="pmr2.citations.settings", check=False) settings.default_path = '/plone/Members/test_user_1_' context = self.portal request = TestRequest( form={ 'form.widgets.identifier': u'urn:miriam:pubmed:12991237', 'form.buttons.import': 1, }) f = form.CitationImportForm(context, request) f.update() self.assertEqual( self.folder['pmid-12991237'].title, u'A quantitative description of membrane current and its ' 'application to conduction and excitation in nerve.')
def test_user_email_form_render(self): context = self.portal request = TestRequest() form = UserEmailForm(context, request) result = form() self.assertTrue('<textarea' in result)
def test_000_nothing(self): request = TestRequest() page = browser.WorkspaceTraversePage(None, request) self.assertEqual(request.get('rev', None), None) self.assertEqual(request.get('request_subpath', None), None)
def test_basic_render_form(self): request = TestRequest() form = SettingsEditForm(self.layer['portal'], request) form.update() result = form.render() self.assertTrue(result)