Merge lp:~elopio/ubuntuone-testing/open-photo into lp:ubuntuone-testing

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 120
Merged at revision: 109
Proposed branch: lp:~elopio/ubuntuone-testing/open-photo
Merge into: lp:ubuntuone-testing
Prerequisite: lp:~elopio/ubuntuone-testing/add-photo
Diff against target: 165 lines (+107/-12)
4 files modified
config-manager.txt (+1/-1)
ubuntuone/web/tests/sst/photos/u1webp107_openphoto.py (+39/-0)
ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py (+2/-7)
ubuntuone/web/tests/sst/shared/actions/photos.py (+65/-4)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/open-photo
Reviewer Review Type Date Requested Status
Philip Fibiger (community) Approve
Review via email: mp+115068@code.launchpad.net

Commit message

Added the open photo test.
Updated selenium simple test to use the refresh action.

Description of the change

Added the open photo test.
Updated selenium simple test to use the refresh action.

To post a comment you must log in.
Revision history for this message
Philip Fibiger (pfibiger) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config-manager.txt'
2--- config-manager.txt 2012-02-01 22:57:55 +0000
3+++ config-manager.txt 2012-07-16 05:58:24 +0000
4@@ -4,4 +4,4 @@
5 # make clean-sourcedeps update-sourcedeps
6 #
7
8-./sourcecode/selenium-simple-test bzr+ssh://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk;revno=256
9+./sourcecode/selenium-simple-test bzr+ssh://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk;revno=274
10
11=== added file 'ubuntuone/web/tests/sst/photos/u1webp107_openphoto.py'
12--- ubuntuone/web/tests/sst/photos/u1webp107_openphoto.py 1970-01-01 00:00:00 +0000
13+++ ubuntuone/web/tests/sst/photos/u1webp107_openphoto.py 2012-07-16 05:58:24 +0000
14@@ -0,0 +1,39 @@
15+# -*- coding: utf-8 -*-
16+
17+# Copyright 2012 Canonical Ltd.
18+#
19+# This program is free software: you can redistribute it and/or modify it
20+# under the terms of the GNU General Public License version 3, as published
21+# by the Free Software Foundation.
22+#
23+# This program is distributed in the hope that it will be useful, but
24+# WITHOUT ANY WARRANTY; without even the implied warranties of
25+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
26+# PURPOSE. See the GNU General Public License for more details.
27+#
28+# You should have received a copy of the GNU General Public License along
29+# with this program. If not, see <http://www.gnu.org/licenses/>.
30+
31+from sst.actions import *
32+from os import path, remove
33+import actions.setup as setup_actions
34+import actions.files as files_actions
35+import actions.photos as photos_actions
36+from utils.randomphotos import make_random_photo_and_return_path
37+
38+setup_actions.setup(new_user=False)
39+random_photo_path = make_random_photo_and_return_path()
40+files_actions.open()
41+files_actions.upload_file(random_photo_path)
42+remove(random_photo_path)
43+random_photo_name = path.basename(random_photo_path)
44+# XXX refresh because there is a bug in edge server.
45+# See https://bugs.launchpad.net/ubuntuone-servers/+bug/1007147
46+refresh()
47+files_actions.assert_file_exists(random_photo_name)
48+photos_actions.open()
49+photo_id = photos_actions.get_photo_id(random_photo_name)
50+photos_actions.open_photo(random_photo_name)
51+photos_actions.assert_photo_name_in_gallery(random_photo_name)
52+photos_actions.assert_photo_is_present_in_gallery(photo_id)
53+photos_actions.assert_photo_is_present_in_gallery_sidebar(photo_id)
54
55=== modified file 'ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py'
56--- ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py 2012-07-16 05:58:24 +0000
57+++ ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py 2012-07-16 05:58:24 +0000
58@@ -20,13 +20,8 @@
59 import actions.files as files_actions
60 import actions.photos as photos_actions
61 from utils.randomphotos import make_random_photo_and_return_path
62-import uuid
63-import tempfile
64-import numpy
65-import Image
66
67 setup_actions.setup(new_user=False)
68-
69 random_photo_path = make_random_photo_and_return_path()
70 files_actions.open()
71 files_actions.upload_file(random_photo_path)
72@@ -34,7 +29,7 @@
73 random_photo_name = path.basename(random_photo_path)
74 # XXX refresh because there is a bug in edge server.
75 # See https://bugs.launchpad.net/ubuntuone-servers/+bug/1007147
76-files_actions.open()
77+refresh()
78 files_actions.assert_file_exists(random_photo_name)
79 photos_actions.open()
80-photos_actions.assert_photo_present_in_list(random_photo_name)
81+photos_actions.assert_photo_is_present_in_list(random_photo_name)
82
83=== modified file 'ubuntuone/web/tests/sst/shared/actions/photos.py'
84--- ubuntuone/web/tests/sst/shared/actions/photos.py 2012-07-16 05:58:24 +0000
85+++ ubuntuone/web/tests/sst/shared/actions/photos.py 2012-07-16 05:58:24 +0000
86@@ -47,14 +47,75 @@
87 assert_text(heading1_element, folder_name)
88
89
90-def assert_photo_present_in_list(photo_name):
91+# List view actions.
92+# TODO make sure we are viewing the photo list.
93+
94+def assert_photo_is_present_in_list(photo_name):
95+ photo_link = _get_photo_link_in_list(photo_name)
96+ assert_displayed(photo_element)
97+
98+
99+def _get_photo_link_in_list(photo_name):
100+ return get_element('.photo-list a[data-u1name="%(name)s"]'
101+ % {'name': photo_name})
102+
103+
104+def get_photo_id(photo_name):
105+ photo_link = _get_photo_link_in_list(photo_name)
106+ return photo_link.get_attribute('data-u1nodekey')
107+
108+
109+def open_photo(photo_name):
110 photo_element = _get_photo_element_in_list(photo_name)
111- assert_displayed(photo_element)
112+ click_element(photo_element)
113+ # XXX find a better way to wait for the gallery to load.
114+ sleep(10)
115
116
117 def _get_photo_element_in_list(photo_name):
118- return get_element('.photo-list img.scaled[data-qa-id="%(name)s"]'
119- % {'name': photo_name})
120+ photo_link = _get_photo_link_in_list(photo_name)
121+ return photo_link.find_element_by_css_selector('img')
122+
123+
124+# Gallery view actions.
125+# TODO make sure we are viewing the photo gallery.
126+
127+def assert_photo_name_in_gallery(photo_name):
128+ heading1_element = get_element_by_css('.title h1')
129+ assert_text(heading1_element, photo_name)
130+
131+def assert_photo_is_present_in_gallery(photo_id):
132+ photo_element = _get_photo_element_in_gallery(photo_id)
133+ assert_displayed(photo_element)
134+
135+
136+def _get_photo_element_in_gallery(photo_id):
137+ photo_css_locator = _get_photo_element_css_locator_in_gallery(photo_id)
138+ return get_element_by_css(photo_css_locator)
139+
140+
141+def _get_photo_element_css_locator_in_gallery(photo_id):
142+ # TODO take into account staging url.
143+ photo_source_url_format = 'https://files.one.ubuntu.com/thumbnail/file_storage/{0}/1000x1000'
144+ photo_source_url = photo_source_url_format.format(photo_id)
145+ return '.photoset .photo > img[src="{0}"]'.format(photo_source_url)
146+
147+
148+def assert_photo_is_present_in_gallery_sidebar(photo_id):
149+ photo_element = _get_photo_element_in_gallery_sidebar(photo_id)
150+ assert_displayed(photo_element)
151+
152+
153+def _get_photo_element_in_gallery_sidebar(photo_id):
154+ photo_css_locator = _get_photo_element_css_locator_in_gallery_sidebar(photo_id)
155+ return get_element_by_css(photo_css_locator)
156+
157+
158+def _get_photo_element_css_locator_in_gallery_sidebar(photo_id):
159+ # TODO take into account staging url.
160+ photo_source_url_format = 'https://files.one.ubuntu.com/thumbnail/file_storage/{0}/108x108/'
161+ photo_source_url = photo_source_url_format.format(photo_id)
162+ return '.photoset .sidebar img[src="{0}"]'.format(photo_source_url)
163
164
165 def _get_md5(filename):

Subscribers

People subscribed via source and target branches