Merge lp:~elopio/ubuntuone-testing/sst-contacts into lp:ubuntuone-testing
- sst-contacts
- Merge into trunk
Proposed by
Leo Arias
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 45 |
Merged at revision: | 47 |
Proposed branch: | lp:~elopio/ubuntuone-testing/sst-contacts |
Merge into: | lp:ubuntuone-testing |
Diff against target: |
739 lines (+707/-0) 6 files modified
ubuntuone/web/tests/sst/contacts/u1webc001_addcontact.py (+38/-0) ubuntuone/web/tests/sst/contacts/u1webc002_editcontact.py (+46/-0) ubuntuone/web/tests/sst/contacts/u1webc003_deletecontact.py (+42/-0) ubuntuone/web/tests/sst/shared/actions/contacts.py (+346/-0) ubuntuone/web/tests/sst/shared/actions/loading.py (+31/-0) ubuntuone/web/tests/sst/shared/data/contact.py (+204/-0) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-testing/sst-contacts |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rick McBride (community) | Approve | ||
Review via email:
|
Commit message
Added the actions and tests for contacts on the website (Fixes LP: #877934)
Description of the change
Added the actions and tests for contacts on the website (LP: #877934)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'ubuntuone/web/tests/sst/contacts' | |||
2 | === added file 'ubuntuone/web/tests/sst/contacts/u1webc001_addcontact.py' | |||
3 | --- ubuntuone/web/tests/sst/contacts/u1webc001_addcontact.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ ubuntuone/web/tests/sst/contacts/u1webc001_addcontact.py 2011-10-19 06:57:26 +0000 | |||
5 | @@ -0,0 +1,38 @@ | |||
6 | 1 | # -*- coding: utf-8 -*- | ||
7 | 2 | |||
8 | 3 | # Copyright 2011 Canonical Ltd. | ||
9 | 4 | # | ||
10 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
11 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
12 | 7 | # by the Free Software Foundation. | ||
13 | 8 | # | ||
14 | 9 | # This program is distributed in the hope that it will be useful, but | ||
15 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
16 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
17 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
18 | 13 | # | ||
19 | 14 | # You should have received a copy of the GNU General Public License along | ||
20 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | 16 | |||
22 | 17 | """Test case u1webc-001 Add Contact. | ||
23 | 18 | Add a contact to Ubuntu One through the website. | ||
24 | 19 | |||
25 | 20 | """ | ||
26 | 21 | |||
27 | 22 | import uuid | ||
28 | 23 | from sst.actions import * | ||
29 | 24 | import actions.setup as setup_actions | ||
30 | 25 | import actions.contacts as contacts_actions | ||
31 | 26 | from data.contact import Contact | ||
32 | 27 | from data.contact import Name | ||
33 | 28 | from data.contact import Email | ||
34 | 29 | |||
35 | 30 | setup_actions.setup() | ||
36 | 31 | contacts_actions.open() | ||
37 | 32 | contact_uuid = uuid.uuid1() | ||
38 | 33 | name = Name(first_name='Test first name %s' % contact_uuid, | ||
39 | 34 | last_name='Test last name %s' % contact_uuid) | ||
40 | 35 | email = Email('Other', 'test-%s@example.com' % contact_uuid) | ||
41 | 36 | contact = Contact(name, (email,)) | ||
42 | 37 | contacts_actions.add_contact(contact) | ||
43 | 38 | contacts_actions.assert_contact_information(contact) | ||
44 | 0 | 39 | ||
45 | === added file 'ubuntuone/web/tests/sst/contacts/u1webc002_editcontact.py' | |||
46 | --- ubuntuone/web/tests/sst/contacts/u1webc002_editcontact.py 1970-01-01 00:00:00 +0000 | |||
47 | +++ ubuntuone/web/tests/sst/contacts/u1webc002_editcontact.py 2011-10-19 06:57:26 +0000 | |||
48 | @@ -0,0 +1,46 @@ | |||
49 | 1 | # -*- coding: utf-8 -*- | ||
50 | 2 | |||
51 | 3 | # Copyright 2011 Canonical Ltd. | ||
52 | 4 | # | ||
53 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
54 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
55 | 7 | # by the Free Software Foundation. | ||
56 | 8 | # | ||
57 | 9 | # This program is distributed in the hope that it will be useful, but | ||
58 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
59 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
60 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
61 | 13 | # | ||
62 | 14 | # You should have received a copy of the GNU General Public License along | ||
63 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
64 | 16 | |||
65 | 17 | """Test case u1webc-002 Edit Contact. | ||
66 | 18 | Edit a contact stored on Ubuntu One through the website. | ||
67 | 19 | |||
68 | 20 | """ | ||
69 | 21 | |||
70 | 22 | import uuid | ||
71 | 23 | from sst.actions import * | ||
72 | 24 | import actions.setup as setup_actions | ||
73 | 25 | import actions.contacts as contacts_actions | ||
74 | 26 | from data.contact import Contact | ||
75 | 27 | from data.contact import Name | ||
76 | 28 | from data.contact import Email | ||
77 | 29 | |||
78 | 30 | setup_actions.setup() | ||
79 | 31 | contacts_actions.open() | ||
80 | 32 | contact_uuid = uuid.uuid1() | ||
81 | 33 | name = Name(first_name='Test first name %s' % contact_uuid, | ||
82 | 34 | last_name='Test last name %s' % contact_uuid) | ||
83 | 35 | email = Email('Other', 'test-%s@example.com' % contact_uuid) | ||
84 | 36 | contact = Contact(name, (email,)) | ||
85 | 37 | contacts_actions.add_contact(contact) | ||
86 | 38 | contacts_actions.assert_contact_information(contact) | ||
87 | 39 | edited_name = Name(first_name='Edited ' + name.first_name, | ||
88 | 40 | last_name='Edited ' + name.last_name) | ||
89 | 41 | edited_email = Email(email.description, 'edited' + email.address) | ||
90 | 42 | edited_contact = Contact(edited_name, (edited_email,)) | ||
91 | 43 | # This will also assert that the original email is not present in the list. | ||
92 | 44 | # If it were, test will fail because two elements with the same id were found. | ||
93 | 45 | contacts_actions.edit_contact(edited_contact) | ||
94 | 46 | contacts_actions.assert_contact_information(edited_contact) | ||
95 | 0 | 47 | ||
96 | === added file 'ubuntuone/web/tests/sst/contacts/u1webc003_deletecontact.py' | |||
97 | --- ubuntuone/web/tests/sst/contacts/u1webc003_deletecontact.py 1970-01-01 00:00:00 +0000 | |||
98 | +++ ubuntuone/web/tests/sst/contacts/u1webc003_deletecontact.py 2011-10-19 06:57:26 +0000 | |||
99 | @@ -0,0 +1,42 @@ | |||
100 | 1 | # -*- coding: utf-8 -*- | ||
101 | 2 | |||
102 | 3 | # Copyright 2011 Canonical Ltd. | ||
103 | 4 | # | ||
104 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
105 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
106 | 7 | # by the Free Software Foundation. | ||
107 | 8 | # | ||
108 | 9 | # This program is distributed in the hope that it will be useful, but | ||
109 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
110 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
111 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
112 | 13 | # | ||
113 | 14 | # You should have received a copy of the GNU General Public License along | ||
114 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
115 | 16 | |||
116 | 17 | """Test case u1webc-003 Delete Contact. | ||
117 | 18 | Delete a contact from Ubuntu One through the website. | ||
118 | 19 | |||
119 | 20 | """ | ||
120 | 21 | |||
121 | 22 | import uuid | ||
122 | 23 | from sst.actions import * | ||
123 | 24 | import actions.setup as setup_actions | ||
124 | 25 | import actions.contacts as contacts_actions | ||
125 | 26 | from data.contact import Contact | ||
126 | 27 | from data.contact import Name | ||
127 | 28 | from data.contact import Email | ||
128 | 29 | |||
129 | 30 | setup_actions.setup() | ||
130 | 31 | contacts_actions.open() | ||
131 | 32 | contact_uuid = uuid.uuid1() | ||
132 | 33 | name = Name(first_name='Test first name %s' % contact_uuid, | ||
133 | 34 | last_name='Test last name %s' % contact_uuid) | ||
134 | 35 | email = Email('Other', 'test-%s@example.com' % contact_uuid) | ||
135 | 36 | contact = Contact(name, (email,)) | ||
136 | 37 | contacts_actions.add_contact(contact) | ||
137 | 38 | contacts_actions.assert_contact_information(contact) | ||
138 | 39 | contact_identifier = contacts_actions.get_contact_identifier() | ||
139 | 40 | contacts_actions.assert_contact_exists(contact_identifier) | ||
140 | 41 | contacts_actions.delete_contact() | ||
141 | 42 | fails(contacts_actions.assert_contact_exists, contact_identifier) | ||
142 | 0 | 43 | ||
143 | === added file 'ubuntuone/web/tests/sst/shared/actions/contacts.py' | |||
144 | --- ubuntuone/web/tests/sst/shared/actions/contacts.py 1970-01-01 00:00:00 +0000 | |||
145 | +++ ubuntuone/web/tests/sst/shared/actions/contacts.py 2011-10-19 06:57:26 +0000 | |||
146 | @@ -0,0 +1,346 @@ | |||
147 | 1 | # -*- coding: utf-8 -*- | ||
148 | 2 | |||
149 | 3 | # Copyright 2011 Canonical Ltd. | ||
150 | 4 | # | ||
151 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
152 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
153 | 7 | # by the Free Software Foundation. | ||
154 | 8 | # | ||
155 | 9 | # This program is distributed in the hope that it will be useful, but | ||
156 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
157 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
158 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
159 | 13 | # | ||
160 | 14 | # You should have received a copy of the GNU General Public License along | ||
161 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
162 | 16 | |||
163 | 17 | """Actions for the Contacts page of the Ubuntu One website.""" | ||
164 | 18 | |||
165 | 19 | from sst.actions import * | ||
166 | 20 | from loading import * | ||
167 | 21 | from data.contact import Contact | ||
168 | 22 | |||
169 | 23 | def open(): | ||
170 | 24 | """Open the Contacts page and assert it's title.""" | ||
171 | 25 | goto('/contacts/') | ||
172 | 26 | assert_title() | ||
173 | 27 | |||
174 | 28 | def assert_title(): | ||
175 | 29 | """Assert that the title of the page is the expected.""" | ||
176 | 30 | title_is(u'Ubuntu One : Contacts') | ||
177 | 31 | |||
178 | 32 | def add_contact(contact): | ||
179 | 33 | """Add a new contact. | ||
180 | 34 | |||
181 | 35 | Keyword arguments: | ||
182 | 36 | contact -- The contact that will be added. | ||
183 | 37 | |||
184 | 38 | """ | ||
185 | 39 | link_add = get_element(css_class='add-button') | ||
186 | 40 | link_click(link_add) | ||
187 | 41 | wait_for_action_to_complete() | ||
188 | 42 | _fill_contact(contact) | ||
189 | 43 | link_save = get_elements(css_class='save-button')[0] | ||
190 | 44 | element_click(link_save) | ||
191 | 45 | wait_for_action_to_complete() | ||
192 | 46 | |||
193 | 47 | def edit_contact(edited_contact): | ||
194 | 48 | """Edit the information of the opened contact. | ||
195 | 49 | |||
196 | 50 | Keyword arguments: | ||
197 | 51 | edited_contact -- The contact with the edited information. | ||
198 | 52 | |||
199 | 53 | """ | ||
200 | 54 | link_edit = get_element(css_class='edit-button') | ||
201 | 55 | element_click(link_edit) | ||
202 | 56 | wait_for_action_to_complete() | ||
203 | 57 | _fill_contact(edited_contact) | ||
204 | 58 | link_save = get_elements(css_class='save-button')[0] | ||
205 | 59 | element_click(link_save) | ||
206 | 60 | wait_for_action_to_complete() | ||
207 | 61 | |||
208 | 62 | def _fill_contact(contact): | ||
209 | 63 | """Fill the contact information. | ||
210 | 64 | |||
211 | 65 | Keyword arguments: | ||
212 | 66 | contact -- The contact with the information that will be filled. | ||
213 | 67 | |||
214 | 68 | """ | ||
215 | 69 | if contact.name: | ||
216 | 70 | _fill_contact_name(contact.name) | ||
217 | 71 | _fill_contact_emails(contact.emails) | ||
218 | 72 | _fill_contact_phones(contact.phones) | ||
219 | 73 | _fill_contact_addresses(contact.addresses) | ||
220 | 74 | _fill_contact_instant_messaging_addresses( | ||
221 | 75 | contact.instant_messaging_addresses) | ||
222 | 76 | _fill_contact_urls(contact.urls) | ||
223 | 77 | if contact.role: | ||
224 | 78 | _fill_contact_role(contact.role) | ||
225 | 79 | if contact.about_information: | ||
226 | 80 | _fill_contact_about_information(contact.about_information) | ||
227 | 81 | |||
228 | 82 | def _fill_contact_name(name): | ||
229 | 83 | """Fill the contact name information. | ||
230 | 84 | |||
231 | 85 | Keyword arguments: | ||
232 | 86 | name -- The name of the contact. | ||
233 | 87 | |||
234 | 88 | """ | ||
235 | 89 | if name.title: | ||
236 | 90 | textfield_write('names-title', name.title) | ||
237 | 91 | if name.first_name: | ||
238 | 92 | textfield_write('names-first_name', name.first_name) | ||
239 | 93 | if name.middle_name: | ||
240 | 94 | textfield_write('names-middle_name', name.middle_name) | ||
241 | 95 | if name.last_name: | ||
242 | 96 | textfield_write('names-last_name', name.last_name) | ||
243 | 97 | if name.suffix: | ||
244 | 98 | textfield_write('names-suffix', name.suffix) | ||
245 | 99 | |||
246 | 100 | def _fill_contact_emails(emails): | ||
247 | 101 | """Fill the contact emails information. | ||
248 | 102 | |||
249 | 103 | Keyword arguments: | ||
250 | 104 | emails -- A sequence with the emails of the contact. | ||
251 | 105 | |||
252 | 106 | """ | ||
253 | 107 | for index, email in enumerate(emails): | ||
254 | 108 | set_select('%d-email_addresses-description' % index, | ||
255 | 109 | email.description) | ||
256 | 110 | textfield_write('%d-email_addresses-address' % index, email.address) | ||
257 | 111 | element_click('add-email-address') | ||
258 | 112 | |||
259 | 113 | def _fill_contact_phones(phones): | ||
260 | 114 | """Fill the contact phones information. | ||
261 | 115 | |||
262 | 116 | Keyword arguments: | ||
263 | 117 | phones -- A sequence with the phones of the contact. | ||
264 | 118 | |||
265 | 119 | """ | ||
266 | 120 | for index, phone in enumerate(phones): | ||
267 | 121 | set_select('%d-phone_numbers-description' % index, phone.description) | ||
268 | 122 | textfield_write('%d-phone_numbers-number' % index, phone.number) | ||
269 | 123 | element_click('add-phone-number') | ||
270 | 124 | |||
271 | 125 | def _fill_contact_addresses(addresses): | ||
272 | 126 | """Fill the contact addresses information. | ||
273 | 127 | |||
274 | 128 | Keyword arguments: | ||
275 | 129 | addresses -- A sequence with the addresses of the contact. | ||
276 | 130 | |||
277 | 131 | """ | ||
278 | 132 | for index, address in enumerate(addresses): | ||
279 | 133 | set_select('%d-addresses-description' % index, address.description) | ||
280 | 134 | textfield_write('%d-addresses-address1' % index, address.address1) | ||
281 | 135 | textfield_write('%d-addresses-address2' % index, address.address2) | ||
282 | 136 | textfield_write('%d-addresses-pobox' % index, address.po_box) | ||
283 | 137 | textfield_write('%d-addresses-city' % index, address.city) | ||
284 | 138 | textfield_write('%d-addresses-state' % index, address.state) | ||
285 | 139 | textfield_write('%d-addresses-postalcode' % index, address.postal_code) | ||
286 | 140 | textfield_write('%d-addresses-country' % index, address.country) | ||
287 | 141 | element_click('add-postal-address') | ||
288 | 142 | |||
289 | 143 | def _fill_contact_instant_messaging_addresses(instant_messaging_addresses): | ||
290 | 144 | """Fill the contact instant messaging information. | ||
291 | 145 | |||
292 | 146 | Keyword arguments: | ||
293 | 147 | instant_messaging_addresses -- A sequence of instant messaging addresses. | ||
294 | 148 | |||
295 | 149 | """ | ||
296 | 150 | for index, address in enumerate(instant_messaging_addresses): | ||
297 | 151 | set_select('%d-im_addresses-description' % index, address.description) | ||
298 | 152 | textfield_write('%d-im_addresses-address' % index, address.address) | ||
299 | 153 | element_click('add-im-address') | ||
300 | 154 | |||
301 | 155 | def _fill_contact_urls(urls): | ||
302 | 156 | """Fill the contact URLs information. | ||
303 | 157 | |||
304 | 158 | Keyword arguments: | ||
305 | 159 | urls -- A sequence with the URLs of the contact. | ||
306 | 160 | |||
307 | 161 | """ | ||
308 | 162 | for index, url in enumerate(urls): | ||
309 | 163 | textfield_write('%d-urls-description' % index, url.description) | ||
310 | 164 | textfield_write('%d--urls-address' % index, url.url) | ||
311 | 165 | element_click('add-url') | ||
312 | 166 | |||
313 | 167 | def _fill_contact_role(role): | ||
314 | 168 | """Fill the contact role information. | ||
315 | 169 | |||
316 | 170 | Keyword arguments: | ||
317 | 171 | role -- The job role information of the contact. | ||
318 | 172 | |||
319 | 173 | """ | ||
320 | 174 | if role.company: | ||
321 | 175 | textfield_write('work-company', role.company) | ||
322 | 176 | if role.department: | ||
323 | 177 | textfield_write('work-department', role.department) | ||
324 | 178 | if role.job_title: | ||
325 | 179 | textfield_write('work-job_title', role.job_title) | ||
326 | 180 | if role.manager_name: | ||
327 | 181 | textfield_write('work-manager_name', role.manager_name) | ||
328 | 182 | if role.assitant_name: | ||
329 | 183 | textfield_write('work-assistant_name', role.assistant_name) | ||
330 | 184 | |||
331 | 185 | def _fill_contact_about_information(about_information): | ||
332 | 186 | """Fill the additional information about the contact. | ||
333 | 187 | |||
334 | 188 | Keyword arguments: | ||
335 | 189 | about_information -- The additional information about the contact. | ||
336 | 190 | |||
337 | 191 | """ | ||
338 | 192 | if about_information.nickname: | ||
339 | 193 | textfield_write('personal-nick_name', about_information.nickname) | ||
340 | 194 | if about_information.birth_date: | ||
341 | 195 | textfield_write('personal-birth_date', about_information.birth_date) | ||
342 | 196 | if about_information.spouse_name: | ||
343 | 197 | textfield_write('personal-spouse_name', about_information.spouse_name) | ||
344 | 198 | if about_information.wedding_date: | ||
345 | 199 | textfield_write('personal-wedding_date', | ||
346 | 200 | about_information.wedding_date) | ||
347 | 201 | if about_information.notes: | ||
348 | 202 | textfield_write('personal-notes', about_information.notes) | ||
349 | 203 | |||
350 | 204 | def assert_contact_information(contact): | ||
351 | 205 | """Assert that the information of the displayed contact is the expected. | ||
352 | 206 | |||
353 | 207 | Keyword arguments: | ||
354 | 208 | contact -- The expected contact information. | ||
355 | 209 | |||
356 | 210 | """ | ||
357 | 211 | _assert_contact_name(contact.name) | ||
358 | 212 | _assert_contact_emails(contact.emails) | ||
359 | 213 | contact_identifier = get_contact_identifier() | ||
360 | 214 | _assert_contact_in_list(contact_identifier, contact) | ||
361 | 215 | # TODO _assert_contact_phones(contact.phones) | ||
362 | 216 | # TODO _assert_contact_addresses(contact.addresses) | ||
363 | 217 | # TODO _assert_contact_instant_messaging_addresses( | ||
364 | 218 | # contact.instant_messaging_addresses) | ||
365 | 219 | # TODO _assert_contact_urls(contact.urls) | ||
366 | 220 | # TODO _assert_contact_role(contact.role) | ||
367 | 221 | # TODO _assert_contact_about_information(contact.about_information) | ||
368 | 222 | |||
369 | 223 | def get_contact_identifier(): | ||
370 | 224 | """Get the identifier of the opened contact.""" | ||
371 | 225 | button_edit = get_element_by_css('.edit-button') | ||
372 | 226 | return button_edit.get_attribute('id') | ||
373 | 227 | |||
374 | 228 | def _get_element_contact_record(identifier): | ||
375 | 229 | """Get the contact record element from the contacts list. | ||
376 | 230 | |||
377 | 231 | Keyword arguments: | ||
378 | 232 | identifier -- The identifier of the contact. | ||
379 | 233 | |||
380 | 234 | """ | ||
381 | 235 | return get_element(id=identifier, css_class='contact-record') | ||
382 | 236 | |||
383 | 237 | def _assert_contact_in_list(contact_identifier, contact_information): | ||
384 | 238 | """Assert that the contact appears on the right place on the contacts list. | ||
385 | 239 | |||
386 | 240 | Keyword arguments: | ||
387 | 241 | contact_identifier -- The identifier of the contact. | ||
388 | 242 | contact_information -- The expected contact information. | ||
389 | 243 | |||
390 | 244 | """ | ||
391 | 245 | # TODO to assert that the contact is under the right letter we need it to | ||
392 | 246 | # have separate divs for each letter. | ||
393 | 247 | # first_letter = _get_contact_letter_in_list(contact.name) | ||
394 | 248 | display_name = _get_contact_display_name_in_list(contact_information.name) | ||
395 | 249 | element_contact = _get_element_contact_record(contact_identifier) | ||
396 | 250 | element_name = element_contact.find_element_by_css_selector('.name a') | ||
397 | 251 | text_is(element_name, display_name) | ||
398 | 252 | if contact_information.emails: | ||
399 | 253 | element_email = element_contact.find_element_by_css_selector('.email') | ||
400 | 254 | text_is(element_email, contact_information.emails[0].address) | ||
401 | 255 | |||
402 | 256 | def _get_contact_display_name_in_list(name): | ||
403 | 257 | """Get the expected name to display in the contacts list. | ||
404 | 258 | |||
405 | 259 | Keyword arguments: | ||
406 | 260 | name -- The name information of the contact. | ||
407 | 261 | |||
408 | 262 | """ | ||
409 | 263 | if name and (name.last_name or name.first_name): | ||
410 | 264 | names = [] | ||
411 | 265 | if name.last_name: | ||
412 | 266 | names.append(name.last_name) | ||
413 | 267 | if name.first_name: | ||
414 | 268 | names.append(name.first_name) | ||
415 | 269 | display_name = ', '.join(names) | ||
416 | 270 | else: | ||
417 | 271 | display_name = 'New contact' | ||
418 | 272 | return display_name | ||
419 | 273 | |||
420 | 274 | def _get_contact_letter_in_list(name): | ||
421 | 275 | """Get the letter under which it's expected to find the contact in the | ||
422 | 276 | list. | ||
423 | 277 | |||
424 | 278 | Keyword arguments: | ||
425 | 279 | name -- The name information of the contact. | ||
426 | 280 | |||
427 | 281 | """ | ||
428 | 282 | if name and (name.last_name or name.first_name): | ||
429 | 283 | if name.last_name: | ||
430 | 284 | first_letter = name.last_name[0] | ||
431 | 285 | else: | ||
432 | 286 | first_letter = name.first_name[0] | ||
433 | 287 | else: | ||
434 | 288 | first_letter = '0' # TODO ask if this is the correct behavior. | ||
435 | 289 | |||
436 | 290 | def _assert_contact_name(name): | ||
437 | 291 | """Assert that the name of the displayed contact is the expected. | ||
438 | 292 | |||
439 | 293 | Keyword arguments: | ||
440 | 294 | name -- The name information of the contact. | ||
441 | 295 | |||
442 | 296 | """ | ||
443 | 297 | if not name: | ||
444 | 298 | display_name = 'New contact' | ||
445 | 299 | else: | ||
446 | 300 | names = [] | ||
447 | 301 | if name.title: | ||
448 | 302 | names.append(name.title) | ||
449 | 303 | if name.first_name: | ||
450 | 304 | names.append(name.first_name) | ||
451 | 305 | if name.middle_name: | ||
452 | 306 | names.append(name.middle_name) | ||
453 | 307 | if name.last_name: | ||
454 | 308 | names.append(name.last_name) | ||
455 | 309 | if name.suffix: | ||
456 | 310 | names.append(name.suffix) | ||
457 | 311 | display_name = ' '.join(names) | ||
458 | 312 | label = get_element_by_css('#names>h1') | ||
459 | 313 | text_is(label, display_name) | ||
460 | 314 | |||
461 | 315 | def _assert_contact_emails(emails): | ||
462 | 316 | """Assert that the email addresses of the displayed contact are the | ||
463 | 317 | expected. | ||
464 | 318 | |||
465 | 319 | Keyword arguments: | ||
466 | 320 | emails -- A sequence with the expected email addresses. | ||
467 | 321 | |||
468 | 322 | """ | ||
469 | 323 | elements_email_descriptions = get_elements_by_css('#email_addresses dt') | ||
470 | 324 | elements_email_addresses = get_elements_by_css('#email_addresses a') | ||
471 | 325 | for index, email in enumerate(emails): | ||
472 | 326 | text_is(elements_email_descriptions[index], '%s:' % email.description) | ||
473 | 327 | text_is(elements_email_addresses[index], email.address) | ||
474 | 328 | |||
475 | 329 | def delete_contact(): | ||
476 | 330 | """Delete the opened contact.""" | ||
477 | 331 | contact_identifier = get_contact_identifier() | ||
478 | 332 | element_contact = _get_element_contact_record(contact_identifier) | ||
479 | 333 | element_contact_checkbox = element_contact. \ | ||
480 | 334 | find_element_by_css_selector('.contact-delete-checkbox') | ||
481 | 335 | checkbox_set(element_contact_checkbox, True) | ||
482 | 336 | element_click('delete-selected') | ||
483 | 337 | alert_accept('Delete selected contacts?') | ||
484 | 338 | wait_for_action_to_complete() | ||
485 | 339 | |||
486 | 340 | def assert_contact_exists(identifier): | ||
487 | 341 | """Assert that a contact exists. | ||
488 | 342 | |||
489 | 343 | Keyword arguments: | ||
490 | 344 | identifier -- The identifier of the contact. | ||
491 | 345 | """ | ||
492 | 346 | _get_element_contact_record(identifier) | ||
493 | 0 | 347 | ||
494 | === added file 'ubuntuone/web/tests/sst/shared/actions/loading.py' | |||
495 | --- ubuntuone/web/tests/sst/shared/actions/loading.py 1970-01-01 00:00:00 +0000 | |||
496 | +++ ubuntuone/web/tests/sst/shared/actions/loading.py 2011-10-19 06:57:26 +0000 | |||
497 | @@ -0,0 +1,31 @@ | |||
498 | 1 | # -*- coding: utf-8 -*- | ||
499 | 2 | |||
500 | 3 | # Copyright 2011 Canonical Ltd. | ||
501 | 4 | # | ||
502 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
503 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
504 | 7 | # by the Free Software Foundation. | ||
505 | 8 | # | ||
506 | 9 | # This program is distributed in the hope that it will be useful, but | ||
507 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
508 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
509 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
510 | 13 | # | ||
511 | 14 | # You should have received a copy of the GNU General Public License along | ||
512 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
513 | 16 | |||
514 | 17 | """Actions to wait for data loading to complete.""" | ||
515 | 18 | |||
516 | 19 | from sst.actions import * | ||
517 | 20 | |||
518 | 21 | def wait_for_action_to_complete(): | ||
519 | 22 | """Wait for the last action to complete. | ||
520 | 23 | |||
521 | 24 | This function waits for the waiting bar to disappear. | ||
522 | 25 | |||
523 | 26 | """ | ||
524 | 27 | # Added a little sleep because if this function is called to fast before | ||
525 | 28 | # the bar appears tests will fail. | ||
526 | 29 | sleep(3) | ||
527 | 30 | waiting_bar = get_element(css_class='yui3-busy-waiting') | ||
528 | 31 | waitfor(fails, is_displayed, waiting_bar) | ||
529 | 0 | 32 | ||
530 | === added directory 'ubuntuone/web/tests/sst/shared/data' | |||
531 | === added file 'ubuntuone/web/tests/sst/shared/data/__init__.py' | |||
532 | === added file 'ubuntuone/web/tests/sst/shared/data/contact.py' | |||
533 | --- ubuntuone/web/tests/sst/shared/data/contact.py 1970-01-01 00:00:00 +0000 | |||
534 | +++ ubuntuone/web/tests/sst/shared/data/contact.py 2011-10-19 06:57:26 +0000 | |||
535 | @@ -0,0 +1,204 @@ | |||
536 | 1 | # -*- coding: utf-8 -*- | ||
537 | 2 | |||
538 | 3 | # Copyright 2011 Canonical Ltd. | ||
539 | 4 | # | ||
540 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
541 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
542 | 7 | # by the Free Software Foundation. | ||
543 | 8 | # | ||
544 | 9 | # This program is distributed in the hope that it will be useful, but | ||
545 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
546 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
547 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
548 | 13 | # | ||
549 | 14 | # You should have received a copy of the GNU General Public License along | ||
550 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
551 | 16 | |||
552 | 17 | """Data classes for a Contact.""" | ||
553 | 18 | |||
554 | 19 | class Contact: | ||
555 | 20 | "Class for Contact information." | ||
556 | 21 | |||
557 | 22 | def __init__(self, name=None, emails=(), phones=(), addresses=(), | ||
558 | 23 | instant_messaging_addresses=(), urls=(), role=None, | ||
559 | 24 | about_information=None): | ||
560 | 25 | """Class constructor. | ||
561 | 26 | |||
562 | 27 | Keyword arguments: | ||
563 | 28 | name -- The name of the contact. Default is None. | ||
564 | 29 | emails -- A sequence with the emails of the contact. Default is an | ||
565 | 30 | empty tuple. | ||
566 | 31 | phones -- A sequence with the phones of the contact. Default is an | ||
567 | 32 | empty tuple. | ||
568 | 33 | addresses -- A sequence with the addresses of the contac. Default is | ||
569 | 34 | an empty tuple. | ||
570 | 35 | instant_messaging_addresses -- A sequence with the instant messaging | ||
571 | 36 | addresses of the contact. Default is an empty tuple. | ||
572 | 37 | urls -- A sequence with the URLs of the contact. Default is an empty | ||
573 | 38 | tuple. | ||
574 | 39 | role -- The job role of the contact. Default is None. | ||
575 | 40 | about_information -- Additional information of the contact. Default is | ||
576 | 41 | None. | ||
577 | 42 | |||
578 | 43 | """ | ||
579 | 44 | self.name = name | ||
580 | 45 | self.emails = emails | ||
581 | 46 | self.phones = phones | ||
582 | 47 | self.addresses = addresses | ||
583 | 48 | self.instant_messaging_addresses = instant_messaging_addresses | ||
584 | 49 | self.urls = urls | ||
585 | 50 | self.role = role | ||
586 | 51 | self.about_information = about_information | ||
587 | 52 | |||
588 | 53 | class Name: | ||
589 | 54 | """Class for the name of a contact.""" | ||
590 | 55 | |||
591 | 56 | def __init__(self, title=None, first_name=None, middle_name=None, | ||
592 | 57 | last_name=None, suffix=None): | ||
593 | 58 | """Class constructor. | ||
594 | 59 | |||
595 | 60 | Keyword arguments: | ||
596 | 61 | title -- The title of the contact. Default is None. | ||
597 | 62 | first_name -- The first name of the contact. Default is None. | ||
598 | 63 | middle_name -- The middle name of the contact. Default is None. | ||
599 | 64 | last_name -- The last name of the contact. Default is None. | ||
600 | 65 | suffix -- The suffix of the contact. Default is None. | ||
601 | 66 | |||
602 | 67 | """ | ||
603 | 68 | self.title = title | ||
604 | 69 | self.first_name = first_name | ||
605 | 70 | self.middle_name = middle_name | ||
606 | 71 | self.last_name = last_name | ||
607 | 72 | self.suffix = suffix | ||
608 | 73 | |||
609 | 74 | class Email: | ||
610 | 75 | """Class for the email of a contact.""" | ||
611 | 76 | |||
612 | 77 | def __init__(self, description, address): | ||
613 | 78 | """Class constructor. | ||
614 | 79 | |||
615 | 80 | Keyword arguments: | ||
616 | 81 | description -- The description of the email. It can be 'Other', | ||
617 | 82 | 'Home' or Work. | ||
618 | 83 | address -- The email address. | ||
619 | 84 | |||
620 | 85 | """ | ||
621 | 86 | self.description = description | ||
622 | 87 | self.address = address | ||
623 | 88 | |||
624 | 89 | class Phone: | ||
625 | 90 | """Class for the phone of a contact.""" | ||
626 | 91 | |||
627 | 92 | def __init__(self, description, number): | ||
628 | 93 | """Class constructor. | ||
629 | 94 | |||
630 | 95 | Keyword arguments: | ||
631 | 96 | description -- The description of the phone. It can be 'Home', | ||
632 | 97 | 'Mobile', 'Home fax', 'Work', 'Car', 'Pager', 'Work fax', | ||
633 | 98 | 'Assitant', 'Call back', 'Company', 'Other fax', 'Primary', | ||
634 | 99 | 'Telex' or 'Other'. | ||
635 | 100 | number -- The phone number. | ||
636 | 101 | |||
637 | 102 | """ | ||
638 | 103 | self.description = description | ||
639 | 104 | self.number = number | ||
640 | 105 | |||
641 | 106 | class Address: | ||
642 | 107 | """Class for the address of a contact.""" | ||
643 | 108 | |||
644 | 109 | def __init__(self, description, address1=None, address2=None, po_box=None, | ||
645 | 110 | city=None, state=None, postal_code=None, country=None): | ||
646 | 111 | """Class constructor. | ||
647 | 112 | |||
648 | 113 | Keyword arguments: | ||
649 | 114 | description -- The description of the address. It can be 'Home', | ||
650 | 115 | 'Work' or 'Other'. | ||
651 | 116 | address1 -- The first line of the address. Default is None. | ||
652 | 117 | address2 -- The second line of the address. Default is None. | ||
653 | 118 | po_box -- The post office box number. Default is None. | ||
654 | 119 | city -- The name of the city. Default is None. | ||
655 | 120 | state -- The name of the state. Default is None. | ||
656 | 121 | postal_code -- The postal code number. Default is None. | ||
657 | 122 | country -- The name of the country. Default is None. | ||
658 | 123 | |||
659 | 124 | """ | ||
660 | 125 | self.description = description | ||
661 | 126 | self.address1 = address1 | ||
662 | 127 | self.address2 = address2 | ||
663 | 128 | self.po_box = po_box | ||
664 | 129 | self.city = city | ||
665 | 130 | self.state = state | ||
666 | 131 | self.postal_code = postal_code | ||
667 | 132 | self.country = country | ||
668 | 133 | |||
669 | 134 | class InstantMessagingAddress: | ||
670 | 135 | """Class for the Instant Messaging address of a contact.""" | ||
671 | 136 | |||
672 | 137 | def __init__(self, description, address): | ||
673 | 138 | """Class constructor. | ||
674 | 139 | |||
675 | 140 | Keyword arguments: | ||
676 | 141 | description -- The description of the instan messaging address. It can | ||
677 | 142 | be 'AIM', 'Gadu-Gadu', 'GroupWise', 'ICQ', 'IRC', 'Jabber', 'MSN', | ||
678 | 143 | 'Skype', 'Yahoo', or 'Other'. | ||
679 | 144 | address -- The instant messaging address. | ||
680 | 145 | |||
681 | 146 | """ | ||
682 | 147 | self.description = description | ||
683 | 148 | self.address = address | ||
684 | 149 | |||
685 | 150 | class Url: | ||
686 | 151 | """Class for the Universal Resource Locators of a contact.""" | ||
687 | 152 | |||
688 | 153 | def __init__(self, description, url): | ||
689 | 154 | """Class constructor. | ||
690 | 155 | |||
691 | 156 | Keyword arguments: | ||
692 | 157 | description -- The description of the URL. | ||
693 | 158 | url -- The Universal Resource Locator. | ||
694 | 159 | |||
695 | 160 | """ | ||
696 | 161 | self.description = description | ||
697 | 162 | self.url = url | ||
698 | 163 | |||
699 | 164 | class Role: | ||
700 | 165 | """Class for the role of a contact.""" | ||
701 | 166 | |||
702 | 167 | def __init__(self, company=None, department=None, job_title=None, | ||
703 | 168 | manager_name=None, assistant_name=None): | ||
704 | 169 | """Class constructor. | ||
705 | 170 | |||
706 | 171 | Keyword arguments: | ||
707 | 172 | company -- The name of the company. Default is None. | ||
708 | 173 | department -- The name of the department. Default is None. | ||
709 | 174 | job_title -- The name of the job possition. Default is None. | ||
710 | 175 | manager_name -- The name of the manager. Default is None. | ||
711 | 176 | assitant_name -- The name of the assistant. Default is None. | ||
712 | 177 | |||
713 | 178 | """ | ||
714 | 179 | self.company = company | ||
715 | 180 | self.department = department | ||
716 | 181 | self.job_title = job_title | ||
717 | 182 | self.manager_name = manager_name | ||
718 | 183 | self.assitant_name = assitant_name | ||
719 | 184 | |||
720 | 185 | class AboutInformation: | ||
721 | 186 | """Class for additional information about the contact.""" | ||
722 | 187 | |||
723 | 188 | def __init__(self, nickname=None, birth_date=None, spouse_name=None, | ||
724 | 189 | wedding_date=None, notes=None): | ||
725 | 190 | """Class constructor. | ||
726 | 191 | |||
727 | 192 | Keyword arguments: | ||
728 | 193 | nickname -- The nickname. Default is None. | ||
729 | 194 | birth_date -- The date of birth. Default is None. | ||
730 | 195 | spouse_name -- The name of the spouse. Default is None. | ||
731 | 196 | wedding_date -- The date of the wedding. Default is None. | ||
732 | 197 | notes -- Additional notes about the contact. Default is None. | ||
733 | 198 | |||
734 | 199 | """ | ||
735 | 200 | self.nickname = nickname | ||
736 | 201 | self.birth_date = birth_date | ||
737 | 202 | self.spouse_name = spouse_name | ||
738 | 203 | self.wedding_date = wedding_date | ||
739 | 204 | self.notes = notes |
Excellent!