Merge lp:~elopio/ubuntuone-testing/notes into lp:~rmcbride/ubuntuone-testing/webnotesautomation

Proposed by Leo Arias
Status: Merged
Approved by: Rick McBride
Approved revision: 71
Merged at revision: 70
Proposed branch: lp:~elopio/ubuntuone-testing/notes
Merge into: lp:~rmcbride/ubuntuone-testing/webnotesautomation
Diff against target: 290 lines (+137/-76)
6 files modified
ubuntuone/web/tests/sst/notes/additional/_actions.py (+0/-19)
ubuntuone/web/tests/sst/notes/additional/config.py (+0/-2)
ubuntuone/web/tests/sst/notes/u1webnotes001_create.py (+8/-7)
ubuntuone/web/tests/sst/notes/u1webnotes002_edit.py (+17/-15)
ubuntuone/web/tests/sst/notes/u1webnotes003_delete.py (+34/-0)
ubuntuone/web/tests/sst/shared/actions/notes.py (+78/-33)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/notes
Reviewer Review Type Date Requested Status
Rick McBride Approve
Review via email: mp+82478@code.launchpad.net

Commit message

Finished the missing details of notes tests.

Description of the change

Finished the missing details of notes tests.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Rick, feel free to change whatever you want, these are your tests.

Revision history for this message
Rick McBride (rmcbride) wrote :

Thanks! fixes the missing issues and changes what was there to make more sense in context of our current tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'ubuntuone/web/tests/sst/notes/additional'
2=== removed file 'ubuntuone/web/tests/sst/notes/additional/__init__.py'
3=== removed file 'ubuntuone/web/tests/sst/notes/additional/_actions.py'
4--- ubuntuone/web/tests/sst/notes/additional/_actions.py 2011-09-27 18:10:08 +0000
5+++ ubuntuone/web/tests/sst/notes/additional/_actions.py 1970-01-01 00:00:00 +0000
6@@ -1,19 +0,0 @@
7-from sst.actions import *
8-from config import base_url
9-
10-set_base_url(base_url)
11-set_wait_timeout(40)
12-
13-
14-def wait_for_title_to_change(title):
15- waitfor(title_is, title)
16-
17-def login(username, password):
18- goto('/auth/login')
19- wait_for_title_to_change('Log in')
20- is_textfield('id_email')
21- is_textfield('id_password')
22- textfield_write('id_email', username)
23- textfield_write('id_password', password)
24- button_click(get_element(css_class='btn', name='continue'))
25- button_click(get_element(css_class='btn', name='yes'))
26
27=== removed file 'ubuntuone/web/tests/sst/notes/additional/config.py'
28--- ubuntuone/web/tests/sst/notes/additional/config.py 2011-09-27 18:10:08 +0000
29+++ ubuntuone/web/tests/sst/notes/additional/config.py 1970-01-01 00:00:00 +0000
30@@ -1,2 +0,0 @@
31-# set below according to need (staging v production v test instance)
32-base_url = 'https://staging.one.ubuntu.com/'
33
34=== modified file 'ubuntuone/web/tests/sst/notes/u1webnotes001_create.py'
35--- ubuntuone/web/tests/sst/notes/u1webnotes001_create.py 2011-10-27 18:37:05 +0000
36+++ ubuntuone/web/tests/sst/notes/u1webnotes001_create.py 2011-11-17 02:22:23 +0000
37@@ -17,15 +17,16 @@
38 """Test Case u1webnotes_001: Add a note through the WebUI.
39 """
40
41-from sst.actions import *
42-from additional._actions import *
43+import uuid
44 import actions.setup as setup_actions
45 import actions.notes as notes_actions
46
47-name = 'This is a test note'
48-body = 'there are many like it, but this one is mine'
49+note_uuid = uuid.uuid1()
50+title = 'Test note %s' % note_uuid
51+body = 'Body of test note %s' % note_uuid
52+
53 setup_actions.setup()
54 notes_actions.open()
55-exists_element(css_class='add-button', text='Add note')
56-notes_actions.add_note(name, body)
57-notes_actions.assert_note_exists(name)
58+notes_actions.add_note(title, body)
59+notes_actions.assert_note_exists(title)
60+notes_actions.assert_note(title, body)
61
62=== modified file 'ubuntuone/web/tests/sst/notes/u1webnotes002_edit.py'
63--- ubuntuone/web/tests/sst/notes/u1webnotes002_edit.py 2011-10-27 18:40:24 +0000
64+++ ubuntuone/web/tests/sst/notes/u1webnotes002_edit.py 2011-11-17 02:22:23 +0000
65@@ -18,22 +18,24 @@
66 it.
67 """
68
69-from sst.actions import *
70-from additional._actions import *
71+import uuid
72 import actions.setup as setup_actions
73 import actions.notes as notes_actions
74-
75-name = 'This is another test note'
76-body = 'there are many like it, but this one is mine'
77-edited_name = 'This is an edited test note'
78-edited_body = 'there are many like it, and as it turns out mine is not all \
79- that unique.'
80+from sst.actions import *
81+
82+note_uuid = uuid.uuid1()
83+title = 'Test note %s' % note_uuid
84+body = 'Body of test note %s' % note_uuid
85+edited_title = 'edited ' + title
86+edited_body = 'edited ' + body
87+
88 setup_actions.setup()
89 notes_actions.open()
90-exists_element(css_class='add-button', text='Add note')
91-notes_actions.add_note(name, body)
92-notes_actions.assert_note_exists(name)
93-"""Edit a note in the WebUI."""
94-notes_actions.select_note('This is a test note')
95-notes_actions.edit_note(edited_name, edited_body)
96-notes_actions.assert_note_exists(edited_name)
97+notes_actions.add_note(title, body)
98+notes_actions.assert_note_exists(title)
99+notes_actions.select_note(title)
100+notes_actions.edit_note(edited_title, edited_body)
101+fails(notes_actions.assert_note_exists, title)
102+notes_actions.assert_note_exists(edited_title)
103+notes_actions.assert_note(edited_title, edited_body)
104+
105
106=== modified file 'ubuntuone/web/tests/sst/notes/u1webnotes003_delete.py'
107--- ubuntuone/web/tests/sst/notes/u1webnotes003_delete.py 2011-10-26 20:10:37 +0000
108+++ ubuntuone/web/tests/sst/notes/u1webnotes003_delete.py 2011-11-17 02:22:23 +0000
109@@ -0,0 +1,34 @@
110+# -*- coding: utf-8 -*-
111+
112+# Copyright 2011 Canonical Ltd.
113+#
114+# This program is free software: you can redistribute it and/or modify it
115+# under the terms of the GNU General Public License version 3, as published
116+# by the Free Software Foundation.
117+#
118+# This program is distributed in the hope that it will be useful, but
119+# WITHOUT ANY WARRANTY; without even the implied warranties of
120+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
121+# PURPOSE. See the GNU General Public License for more details.
122+#
123+# You should have received a copy of the GNU General Public License along
124+# with this program. If not, see <http://www.gnu.org/licenses/>.
125+
126+"""Test Case u1webnotes_003: Delete a note through the WebUI.
127+"""
128+
129+import uuid
130+import actions.setup as setup_actions
131+import actions.notes as notes_actions
132+
133+note_uuid = uuid.uuid1()
134+title = 'Test note %s' % note_uuid
135+body = 'Body of test note %s' % note_uuid
136+
137+setup_actions.setup()
138+notes_actions.open()
139+notes_actions.add_note(title, body)
140+notes_actions.assert_note_exists(title)
141+notes_actions.assert_note(title, body)
142+notes_actions.delete_note(title)
143+notes_actions.assert_note_was_deleted(title)
144
145=== modified file 'ubuntuone/web/tests/sst/shared/actions/notes.py'
146--- ubuntuone/web/tests/sst/shared/actions/notes.py 2011-10-27 18:37:05 +0000
147+++ ubuntuone/web/tests/sst/shared/actions/notes.py 2011-11-17 02:22:23 +0000
148@@ -18,14 +18,20 @@
149
150 from sst.actions import *
151 from loading import *
152+from selenium.webdriver.common import keys
153
154
155 def open():
156 """Open the notes page and check its title with an assert."""
157- goto('/notes/')
158+ link_click(_get_notes_link(), wait=False)
159+ switch_to_window()
160 assert_title()
161
162
163+def _get_notes_link():
164+ return get_element_by_css('#main-nav .notes')
165+
166+
167 def assert_title():
168 """Assert that the title of the page is the expected."""
169 title_is(u'Ubuntu One : Notes')
170@@ -36,49 +42,88 @@
171
172
173 def select_note(title):
174- button_click(get_elements(tag='li', text=title))
175-
176-
177-def add_note(note, note_body):
178+ link_click(_get_note_link(title))
179+ wait_for_action_to_complete()
180+
181+
182+def _get_note_link(title):
183+ return get_element(tag='a', css_class='note_link', text=title)
184+
185+
186+def assert_note(title, body):
187+ if title:
188+ displayed_title = _get_note_title()
189+ assert displayed_title == title, \
190+ 'Title is %(displayed)s, but it should be %(expected)s.' % \
191+ {'displayed':displayed_title, 'expected':title}
192+ if body:
193+ displayed_body = _get_note_body()
194+ assert displayed_body == body, \
195+ 'Body is %(displayed)s, but it should be %(expected)s.' % \
196+ {'displayed':displayed_body, 'expected':body}
197+
198+
199+def _get_note_title():
200+ return get_element_by_css('#notes-main > h1').text
201+
202+
203+def _get_note_body():
204+ return get_element_by_css('#notes-main > .note-view').text
205+
206+
207+def add_note(title, body):
208 """Click the button to add note."""
209- link_add = get_elements(css_class='add-button', text='Add note')[0]
210+ _click_add_note()
211+ _fill(title, body)
212+ _save()
213+
214+
215+def _click_add_note():
216+ link_add = get_element(css_class='add-button')
217 link_click(link_add)
218 wait_for_action_to_complete()
219- edit_title(note)
220- edit_body(note_body)
221- link_save = get_elements(css_class='save-button', text='Save')[0]
222+
223+
224+def _fill(title, body):
225+ if title:
226+ textfield_write('id_title', title)
227+ if body:
228+ switch_to_frame('id_body_editor')
229+ body_element = get_element(tag='body')
230+ body_element.send_keys(keys.Keys().CONTROL, 'a')
231+ body_element.send_keys(keys.Keys().DELETE)
232+ body_element.send_keys(body)
233+ switch_to_frame()
234+
235+
236+def _save():
237+ link_save = get_elements(css_class='save-button')[0]
238 element_click(link_save)
239 wait_for_action_to_complete()
240
241
242-def edit_note(edited_note, edited_note_body):
243+def edit_note(edited_title, edited_body):
244 """Click the button to edit note."""
245- link_edit = get_elements(css_class='edit-button', text='Edit note')[0]
246+ _click_edit_note()
247+ _fill(edited_title, edited_body)
248+ _save()
249+
250+
251+def _click_edit_note():
252+ link_edit = get_elements(css_class='edit-button')[0]
253 link_click(link_edit)
254 wait_for_action_to_complete()
255- edit_title(edited_note)
256- edit_body(edited_note_body)
257- link_save = get_elements(css_class='save-button', text='Save')[0]
258- element_click(link_save)
259- wait_for_action_to_complete()
260-
261-
262-def delete_note(deleted_note):
263+
264+
265+def delete_note(title):
266 """Delete the note"""
267- note_identifier = get_note_identifier()
268- element_note = _get_element_note_identifier(note_identifier)
269- #somehow select based on identifier. no checkbox in this UI like for
270- #contacts
271- #this is a guess
272- link_click(get_elements(li_class='selected', a_class='delete-button'))
273+ select_note(title)
274+ delete_button = get_element_by_css('li.selected > a.delete-button')
275+ element_click(delete_button)
276+ alert_accept()
277 wait_for_action_to_complete()
278
279
280-def edit_title(title):
281- """Enter the text in the title field."""
282- textfield_write('id_title', title)
283-
284-
285-def edit_body(body):
286- """Enter the body texst in the body field."""
287- textfield_write('id_body_editor', body)
288+def assert_note_was_deleted(title):
289+ fails(assert_note_exists, title)
290+ text_is('notes-main', '"%s" has been deleted' % title)

Subscribers

People subscribed via source and target branches

to all changes: