1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
Adding, Editing, Moving and Deleting a Document
===============================================
A replacement for both the 'rendering.txt' and the 'forms.txt' test.
Does what the title says, really. Plus some assertions.
>>> from Products.Five.testbrowser import Browser
>>> browser = Browser()
>>> browser.open('http://nohost/plone')
First, we need to log in.
>>> browser.getControl('Login Name').value = 'test_user_1_'
>>> browser.getControl('Password').value = 'secret'
>>> browser.getControl('Log in').click()
Add Document
------------
What we do next is we
- go to our home folder,
- add a new page,
- edit some values,
- save the page,
- and along the way we check that everything works as expected.
Note that this is slightly different to how the testrecorder result
looks like because we're navigating the page with a JavaScript- less
browser.
>>> browser.getLink('My Folder').click()
>>> browser.getLink('Add item').click()
>>> 'Add new item' in browser.contents
True
>>> browser.getControl('Add Page').click()
>>> #'Edit Page' in browser.contents # ouch, Plone has <span> around 'Page'
>>> browser.url
'http://nohost/plone/Members/test_user_1_/portal_factory/Document/.../edit'
Now that the document has been added, we can edit it, but we pretend
we don't know better and forget to type in a Title:
>>> browser.getControl('Body Text').value = 'About test_user_1_'
>>> browser.getControl('Save').click()
>>> 'Title is required, please correct.' in browser.contents
True
Oops, let's fill that in quickly:
>>> browser.getControl('Title').value = 'My Page'
>>> browser.getControl('Save').click()
>>> 'Changes saved.' in browser.contents
True
>>> 'My Page' in browser.contents
True
We edit the document a second time:
>>> browser.getLink('Edit').click()
>>> browser.getControl('Title').value = 'Ons Bier'
>>> browser.getControl('Save').click()
>>> 'Ons Bier' in browser.contents
True
Editing Properties
------------------
We edit the document properties:
>>> browser.getLink('Properties').click()
>>> browser.url
'http://nohost/plone/Members/test_user_1_/my-page/properties'
We make sure the language is neutral at the beginning:
>>> browser.getControl(name='language').displayValue
['Language neutral (site default)']
And the content language is set to the default:
>>> browser.headers.dict['content-language']
'en'
Now set the language to German:
>>> browser.getControl(name='language').value = ['de']
>>> browser.getControl(name='language').displayValue
['German']
>>> browser.getControl('Save').click()
>>> 'Changes saved.' in browser.contents
True
Make sure the content language was updated:
>>> browser.headers.dict['content-language']
'de'
Cut and paste Document
----------------------
We'll first cut our Document. Then we'll create folder where we paste
the Document into.
>>> browser.getLink('Actions').click()
First off, we'll cut our document:
>>> browser.getControl('Ons Bier').click()
>>> browser.getControl('Cut').click()
Before doing the actual paste, we create a folder to paste into.
>>> browser.getLink('Add item').click()
>>> 'Add new item' in browser.contents
True
>>> browser.getControl('Add Folder').click()
>>> #'Edit Folder' in browser.contents # empty <span> again
True
>>> browser.getControl('Title').value = 'My Folder'
>>> browser.getControl('Save').click()
>>> 'Changes saved.' in browser.contents
True
The Folder has been created, now we can paste the Document in our copy
buffer here:
>>> browser.getLink('Actions').click()
>>> browser.getControl('Paste').click()
>>> 'Item(s) pasted.' in browser.contents
True
>>> 'Ons Bier' in browser.contents
True
Delete Document
---------------
Again, also deleting a Document without JavaScript involves visiting
the ``folder_contents`` page and clicking a checkbox.
>>> browser.getLink('Actions').click()
>>> browser.url
'http://nohost/plone/Members/test_user_1_/my-folder/folder_contents'
This is how we click the checkbox. There's a nicer way to do this,
I'm sure:
>>> browser.getControl('Ons Bier').click()
>>> browser.getControl('Delete').click()
>>> 'Item(s) deleted.' in browser.contents
True
|