def test_folder__Add__2(address_book, FolderFactory, browser): """It allows duplicate folder titles in different folders.""" folder = FolderFactory(address_book, u'special docs') FolderFactory(address_book, u'foo', parent=folder) browser.login('mgr') browser.open(browser.FOLDER_ADD_URL) browser.getControl('folder title').value = 'foo' browser.getControl('Add').click() assert '"foo" added.' == browser.message assert browser.FOLDER2_IN_ROOT_VIEW_URL == browser.url
def test_folder__Add__1(address_book, FolderFactory, browser): """It requires unique folder titles inside the folder.""" FolderFactory(address_book, u'foolder') browser.login('mgr') browser.open(browser.FOLDER_ADD_URL) browser.getControl('folder title').value = 'foolder' browser.getControl('Add').click() assert 'There were some errors.' in browser.contents assert ('There is already an object with this title in this folder.' in browser.contents)
def test_folder__Edit__2(address_book, FolderFactory, browser): """It allows duplicate folder titles in different folders.""" FolderFactory(address_book, u'bar') folder = FolderFactory(address_book, u'special docs') FolderFactory(address_book, u'foo', parent=folder) browser.login('mgr') browser.open(browser.FOLDER_IN_ROOT_EDIT_URL) browser.getControl('folder title').value = 'foo' browser.getControl('Save').click() assert 'Data successfully updated.' == browser.message assert browser.DOCUMENTS_OVERVIEW_URL == browser.url
def test_folder__List__7(address_book, KeywordFactory, FolderFactory, browser, UserFactory): """Read rights are not inherited to sub folders but from parents. The latter is needed so the user can navigate to the folder he is allowed to read. """ kw_foo = KeywordFactory(address_book, u'foo') kw_bar = KeywordFactory(address_book, u'bar') UserFactory(address_book, u'Valter', u'Vimladil', u'*****@*****.**', u'1qay2wsx', roles=[u'Document user'], keywords=[kw_foo]) UserFactory(address_book, u'Ben', u'Utzer', u'*****@*****.**', u'1qay2wsx', roles=[u'Document user'], keywords=[kw_bar]) foo = FolderFactory(address_book, u'foo folder', read_only=[kw_foo]) sub = FolderFactory(address_book, u'sub folder', parent=foo, read_only=[kw_foo]) FolderFactory(address_book, u'sub folder2', parent=foo, read_only=[kw_foo]) FolderFactory(address_book, u'sub sub2 folder', parent=sub, read_only=[kw_bar]) # Read rights are not inherited to sub folders: browser.formlogin('*****@*****.**', '1qay2wsx') browser.open(browser.DOCUMENTS_OVERVIEW_URL) browser.getLink('foo folder').click() assert browser.FOLDER_IN_ROOT_VIEW_URL == browser.url assert 'sub folder2' in browser.contents browser.getLink('sub folder').click() assert 'sub sub2 folder' not in browser.contents browser.logout() # But a read right in a subfolder allows to access its parent folders. browser.formlogin('*****@*****.**', '1qay2wsx') browser.open(browser.DOCUMENTS_OVERVIEW_URL) browser.getLink('foo folder').click() assert browser.FOLDER_IN_ROOT_VIEW_URL == browser.url assert 'sub folder2' not in browser.contents browser.getLink('sub folder').click() assert 'sub sub2 folder' in browser.contents
def test_checkout_response_should_be_OK_and_a_snarf_archive(self): # XXX flaky, see #10491 browser = zope.testbrowser.browser.Browser() browser.addHeader('Authorization', 'manager:asdf') # The output contains the length of each piece which, in turn, depends # on the length of the etag in the case of folder/file. We need to # make sure that the length of the etag is deterministic. self.app['folder']['file']._EtagSupport__etag = 'ts65399125.34' try: browser.open('http://*****:*****@@toFS.snarf' % self.layer.port) except urllib2.HTTPError, e: self.fail(e)
def test_folder__List__4(address_book, KeywordFactory, FolderFactory, browser, UserFactory): """It shows folders where the user has a keyword of folder's r/w list.""" kw_foo = KeywordFactory(address_book, u'foo') UserFactory(address_book, u'Valter', u'Vimladil', u'*****@*****.**', u'1qay2wsx', roles=[u'Document user'], keywords=[kw_foo]) FolderFactory(address_book, u'foo docs', read_write=[kw_foo]) browser.formlogin('*****@*****.**', '1qay2wsx') browser.open(browser.DOCUMENTS_OVERVIEW_URL) assert browser.FOLDER_IN_ROOT_VIEW_URL == browser.getLink('foo docs').url
def test_folder__Add__List__Edit__Delete__1(address_book, KeywordFactory, browser): """They allow to CRUD a new folder.""" KeywordFactory(address_book, u'kw1') KeywordFactory(address_book, u'kw2') KeywordFactory(address_book, u'kw3') browser.login('mgr') browser.open(browser.DOCUMENTS_OVERVIEW_URL) # Add browser.getLink('folder').click() assert browser.FOLDER_ADD_URL == browser.url browser.getControl('folder title').value = 'föø' assert (['kw1', 'kw2', 'kw3'] == browser.getControl('read only access').displayOptions) browser.getControl('read only access').displayValue = ['kw1', 'kw3'] assert (['kw1', 'kw2', 'kw3' ] == browser.getControl('read and write access').displayOptions) browser.getControl('read and write access').displayValue = ['kw2'] browser.getControl('Add').click() assert u'"föø" added.' == browser.message assert browser.FOLDER_IN_ROOT_VIEW_URL == browser.url # Edit browser.getLink('Documents').click() # back to parent assert 'föø' in browser.contents assert browser.FOLDER_IN_ROOT_EDIT_URL == browser.getLink('Edit').url browser.getLink('Edit').click() assert 'föø' == browser.getControl('folder title').value assert (['kw1', 'kw3'] == browser.getControl('read only access').displayValue) assert ['kw2'] == browser.getControl('read and write access').displayValue browser.getControl('folder title').value = 'bä®' browser.getControl('read only access').displayValue = [] browser.getControl('read and write access').displayValue = ['kw3'] browser.getControl('Save').click() assert 'Data successfully updated.' == browser.message assert browser.DOCUMENTS_OVERVIEW_URL == browser.url # Delete browser.getLink('Delete').click() assert ('Do you really want to delete this folder and all its contents?' in browser.contents) browser.getControl('Yes').click() assert u'"bä®" deleted.' == browser.message assert 'This folder is (currently) empty.' in browser.contents
def test_folder__List__8(folders_and_users, browser): # pragma: no cover """Read/write rights in a sub folder result in read rights in the parent. Read/Write rights are not inherited to sub folders. """ # address_book = folders_and_users browser.formlogin('*****@*****.**', 'password') browser.open(browser.DOCUMENTS_OVERVIEW_URL) # The prerequisites for this test are not yet implemented :-( # That's why the test is marked as xfail and "pragma: no cover". browser.getLink('Top 1').click() browser.getLink('Sub 2').click() browser.getLink('Sub 2').click() browser.getLink('Sub 3').click() open('response.html', 'w').write(browser.contents) assert False, 'nyi'
def test_folder__Delete__1(address_book, FolderFactory, DocumentFactory, browser): """It renders the number of contained objects in the are-you-sure-form.""" folder = FolderFactory(address_book, u'for delete') FolderFactory(address_book, u'folder outside') # does not count sub = FolderFactory(address_book, u'sub folder', parent=folder) DocumentFactory(address_book, u'foo', u'foo.txt', parent=folder) DocumentFactory(address_book, u'bar', u'bar.txt', parent=sub) browser.login('mgr') browser.open(browser.DOCUMENTS_OVERVIEW_URL) browser.getLink('Delete', index=1).click() assert browser.FOLDER_IN_ROOT_DELETE_URL == browser.url assert ('number of objects in folder (incl. sub-folders)' in browser.contents) assert ( '<span id="form-widgets-num" class="text-widget int-field">3</span>' in browser.contents)
def test_folder__List__2(address_book, KeywordFactory, DocumentFactory, FolderFactory, UserFactory, browser): """It does not show content objects if the user does not have the ... ... required keywords. """ kw_foo = KeywordFactory(address_book, u'foo') UserFactory(address_book, u'Valter', u'Vimladil', u'*****@*****.**', u'1qay2wsx', roles=[u'Document user']) FolderFactory(address_book, u'foo docs', read_only=[kw_foo]) DocumentFactory(address_book, u'bar', u'bar.txt') browser.formlogin('*****@*****.**', '1qay2wsx') browser.open(browser.DOCUMENTS_OVERVIEW_URL) assert 'This folder is (currently) empty.' in browser.contents
def test_folder__List__6(address_book, KeywordFactory, FolderFactory, browser, UserFactory): """It does not show folders where the user has no access.""" kw_foo = KeywordFactory(address_book, u'foo') kw_bar = KeywordFactory(address_book, u'bar') kw_baz = KeywordFactory(address_book, u'baz') UserFactory(address_book, u'Valter', u'Vimladil', u'*****@*****.**', u'1qay2wsx', roles=[u'Document user'], keywords=[kw_foo]) FolderFactory(address_book, u'foo docs', read_only=[kw_baz], read_write=[kw_bar]) browser.formlogin('*****@*****.**', '1qay2wsx') browser.open(browser.DOCUMENTS_OVERVIEW_URL) with pytest.raises(zope.testbrowser.browser.LinkNotFoundError): browser.getLink('foo docs')
def test_folder__List__1(address_book, UserFactory, browser): """It cannot be accessed without the `Document user` role.""" UserFactory(address_book, u'Valter', u'Vimladil', u'*****@*****.**', u'1qay2wsx', roles=[]) browser.formlogin('*****@*****.**', '1qay2wsx') assert [ 'Master data', 'About', ] == browser.etree.xpath( '//div[@class="menuToggle main-menu"]/ul/li/a/span/text()') with pytest.raises(zope.testbrowser.browser.HTTPError) as err: browser.open(browser.DOCUMENTS_OVERVIEW_URL) assert 'HTTP Error 403: Forbidden' == str(err.value) assert 'You are not authorized.' in browser.contents
if __name__ == '__main__': import random import zope.testbrowser.browser import zope.app.testing.functional browser = zope.testbrowser.browser.Browser() browser.addHeader('Authorization', 'Basic ' + 'admin:admin'.encode('base64')) browser.open( 'http://*****:*****@@refresh-cache') edit_url = ( 'http://localhost:8080/++skin++vivi/workingcopy/zope.manager/blarf/' 'informatives/a6099f69-52a0-4795-bd9d-e6e3359291b8/edit-properties') url = None for i in xrange(100): browser.open(edit_url) if url and url != browser.getControl('URL').value: print "Setting url failed:", url url = 'http://foo.testing/%s' % (i,) print url browser.getControl('URL').value = url browser.getControl('Apply').click() browser.contents