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