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

Proposed by Leo Arias
Status: Merged
Approved by: Philip Fibiger
Approved revision: 119
Merged at revision: 108
Proposed branch: lp:~elopio/ubuntuone-testing/add-photo
Merge into: lp:ubuntuone-testing
Prerequisite: lp:~elopio/ubuntuone-testing/open-photos-tab
Diff against target: 129 lines (+68/-26)
3 files modified
ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py (+32/-25)
ubuntuone/web/tests/sst/shared/actions/photos.py (+10/-1)
ubuntuone/web/tests/sst/shared/utils/randomphotos.py (+26/-0)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/add-photo
Reviewer Review Type Date Requested Status
Philip Fibiger (community) Approve
Review via email: mp+115062@code.launchpad.net

Commit message

Added a utility function to create random photos.
Cleaned the add photo test.

Description of the change

Added a utility function to create random photos.
Cleaned the add photo test.

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

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0, Pending == 0. Got: 1 Pending.

Revision history for this message
Philip Fibiger (pfibiger) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'ubuntuone/web/tests/sst/photos/u1p001_addphoto.py' => 'ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py'
--- ubuntuone/web/tests/sst/photos/u1p001_addphoto.py 2012-06-19 20:29:12 +0000
+++ ubuntuone/web/tests/sst/photos/u1webp83_addphoto.py 2012-07-16 04:51:46 +0000
@@ -1,33 +1,40 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2# Copyright 2012 Canonical Ltd - All rights reserved
32
4""" U1P001 Test to upload a photo. """3# Copyright 2012 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
516
6from sst.actions import *17from sst.actions import *
18from os import path, remove
7import actions.setup as setup_actions19import actions.setup as setup_actions
8import actions.files as files_actions20import actions.files as files_actions
9import actions.photos as photos_actions21import actions.photos as photos_actions
10import os.path22from utils.randomphotos import make_random_photo_and_return_path
11from data.photos import test_files_path, file_name_orig, file_size23import uuid
12from data.user import User24import tempfile
13try:25import numpy
14 from _photopasswords import full_name, email, password26import Image
15except:27
16 skip('Try adding a _photopasswords.py file to the photos folder if you ' \28setup_actions.setup(new_user=False)
17 'expect this to work. Read the README.txt file ;)')29
1830random_photo_path = make_random_photo_and_return_path()
1931files_actions.open()
20test_user = User(full_name, email, password)32files_actions.upload_file(random_photo_path)
21setup_actions.setup(user=test_user)33remove(random_photo_path)
22files_actions.open()34random_photo_name = path.basename(random_photo_path)
23file_path_orig = test_files_path + file_name_orig35# XXX refresh because there is a bug in edge server.
24file_names = photos_actions.generate_unique_files(test_files_path,36# See https://bugs.launchpad.net/ubuntuone-servers/+bug/1007147
25 file_name_orig, 1)37files_actions.open()
26file_path_uniq = test_files_path + file_names[0]38files_actions.assert_file_exists(random_photo_name)
27files_actions.upload_file(os.path.abspath(file_path_uniq))
28photos_actions.clean_test_file(os.path.abspath(file_path_uniq))
29files_actions.open() # refresh because edge is broken.
30files_actions.assert_file_exists(file_names[0])
31assert files_actions.get_file_size(file_names[0]) == file_size
32photos_actions.open()39photos_actions.open()
33photos_actions.assert_photo_is_displayed_on_gallery(file_names[0])40photos_actions.assert_photo_present_in_list(random_photo_name)
3441
=== modified file 'ubuntuone/web/tests/sst/shared/actions/photos.py'
--- ubuntuone/web/tests/sst/shared/actions/photos.py 2012-07-16 04:51:46 +0000
+++ ubuntuone/web/tests/sst/shared/actions/photos.py 2012-07-16 04:51:46 +0000
@@ -28,7 +28,6 @@
28def open():28def open():
29 click_photos_tab()29 click_photos_tab()
30 switch_to_window()30 switch_to_window()
31 assert_page_title()
3231
3332
34def click_photos_tab():33def click_photos_tab():
@@ -48,6 +47,16 @@
48 assert_text(heading1_element, folder_name)47 assert_text(heading1_element, folder_name)
4948
5049
50def assert_photo_present_in_list(photo_name):
51 photo_element = _get_photo_element_in_list(photo_name)
52 assert_displayed(photo_element)
53
54
55def _get_photo_element_in_list(photo_name):
56 return get_element('.photo-list img.scaled[data-qa-id="%(name)s"]'
57 % {'name': photo_name})
58
59
51def _get_md5(filename):60def _get_md5(filename):
52 """ get md5 checksum of file 'filename'. """61 """ get md5 checksum of file 'filename'. """
53 m = hashlib.md5()62 m = hashlib.md5()
5463
=== added file 'ubuntuone/web/tests/sst/shared/utils/randomphotos.py'
--- ubuntuone/web/tests/sst/shared/utils/randomphotos.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/utils/randomphotos.py 2012-07-16 04:51:46 +0000
@@ -0,0 +1,26 @@
1# -*- coding: utf-8 -*-
2
3"""Thanks to heltonbiker for the code to generate the random image.
4See http://stackoverflow.com/a/10901092
5
6As part of the code for this file was copied from stackoverflow,
7it has a CC-BY-SA 3.0 license.
8
9"""
10
11import numpy
12import Image
13import tempfile
14import uuid
15
16def make_random_photo_and_return_path():
17 photo_uuid = str(uuid.uuid1())
18 photo_path = None
19 random_matrix = numpy.random.rand(200, 200, 3) * 255
20 random_uint8_matrix = random_matrix.astype('uint8')
21 image = Image.fromarray(random_uint8_matrix).convert('RGBA')
22 photo = tempfile.NamedTemporaryFile(mode='wr', prefix='Random photo ',
23 suffix=photo_uuid + '.jpg', delete=False)
24 image.save(photo)
25 photo.close
26 return photo.name

Subscribers

People subscribed via source and target branches