Merge lp:~dpniel/ubiquity/check_partitions into lp:ubiquity

Proposed by Dan Chapman 
Status: Merged
Merged at revision: 6068
Proposed branch: lp:~dpniel/ubiquity/check_partitions
Merge into: lp:ubiquity
Diff against target: 181 lines (+88/-30)
5 files modified
autopilot/ubiquity_autopilot_tests/configs/partconfig.py (+1/-1)
autopilot/ubiquity_autopilot_tests/exception.py (+22/-0)
autopilot/ubiquity_autopilot_tests/testcase.py (+7/-4)
autopilot/ubiquity_autopilot_tests/tests/__init__.py (+58/-19)
autopilot/ubiquity_autopilot_tests/tools/_exc.py (+0/-6)
To merge this branch: bzr merge lp:~dpniel/ubiquity/check_partitions
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Review via email: mp+196273@code.launchpad.net

Description of the change

After creating a manual partition, test now checks that the mount point, FS type and size are displayed and correct

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Approved, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/ubiquity_autopilot_tests/configs/partconfig.py'
2--- autopilot/ubiquity_autopilot_tests/configs/partconfig.py 2013-11-19 09:07:08 +0000
3+++ autopilot/ubiquity_autopilot_tests/configs/partconfig.py 2013-11-22 12:32:25 +0000
4@@ -121,7 +121,7 @@
5
6 /tmp = 200MB Ext4
7
8- /home = Ext4 take up available sapce
9+ /home = Ext4 take up available space
10
11 /opt = 500MB Ext3
12
13
14=== added file 'autopilot/ubiquity_autopilot_tests/exception.py'
15--- autopilot/ubiquity_autopilot_tests/exception.py 1970-01-01 00:00:00 +0000
16+++ autopilot/ubiquity_autopilot_tests/exception.py 2013-11-22 12:32:25 +0000
17@@ -0,0 +1,22 @@
18+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
19+#
20+# Copyright (C) 2013
21+#
22+# Author: Daniel Chapman daniel@chapman-mail.com
23+#
24+# This program is free software; you can redistribute it and/or modify
25+# it under the terms of the GNU Lesser General Public License as published by
26+# the Free Software Foundation; version 3.
27+#
28+# This program is distributed in the hope that it will be useful,
29+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# GNU Lesser General Public License for more details.
32+#
33+# You should have received a copy of the GNU Lesser General Public License
34+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35+
36+
37+class NonFatalErrors(AssertionError):
38+ """ Exception class for raising non fatal errors
39+ """
40
41=== modified file 'autopilot/ubiquity_autopilot_tests/testcase.py'
42--- autopilot/ubiquity_autopilot_tests/testcase.py 2013-11-19 09:07:08 +0000
43+++ autopilot/ubiquity_autopilot_tests/testcase.py 2013-11-22 12:32:25 +0000
44@@ -15,6 +15,10 @@
45 #
46 # You should have received a copy of the GNU Lesser General Public License
47 # along with this program. If not, see <http://www.gnu.org/licenses/>.
48+import unittest
49+import traceback
50+import logging
51+
52 from autopilot.testcase import AutopilotTestCase
53 from testtools.testcase import MismatchError
54 from testtools.matchers import (
55@@ -24,12 +28,11 @@
56 Is,
57 IsInstance
58 )
59-import unittest
60 from testtools.content import text_content
61-import traceback
62+
63 from ubiquity_autopilot_tests.tools import compare
64-from ubiquity_autopilot_tests.tools._exc import NonFatalErrors
65-import logging
66+from ubiquity_autopilot_tests.exception import NonFatalErrors
67+
68
69 logger = logging.getLogger(__name__)
70
71
72=== modified file 'autopilot/ubiquity_autopilot_tests/tests/__init__.py'
73--- autopilot/ubiquity_autopilot_tests/tests/__init__.py 2013-11-19 11:52:06 +0000
74+++ autopilot/ubiquity_autopilot_tests/tests/__init__.py 2013-11-22 12:32:25 +0000
75@@ -511,7 +511,7 @@
76 self.assertThat(partition_dialog.visible,
77 Eventually(Equals(False)),
78 "Partition dialog did not close")
79- self._check_partition_created(elem['MountPoint'])
80+ self._check_partition_created(elem)
81 self._check_page_titles()
82 self._check_navigation_buttons()
83
84@@ -704,29 +704,68 @@
85 time.sleep(2)
86 logger.debug('_add_new_partition complete')
87
88- def _check_partition_created(self, mountPoint):
89- """ Checks that the partition was created properly """
90- time.sleep(5)
91- # TODO: This needs fixing
92+ def _check_partition_created(self, config):
93+ """ Checks that the partition was created properly
94+ """
95+ #before checking lets just wait a little while to ensure everything
96+ # has finished loading, this doesn't affect outcome
97+ time.sleep(7)
98+ logger.debug("Checking partition was created.....")
99 custom_page = self.main_window.select_single(
100 'GtkAlignment',
101 BuilderName='stepPartAdvanced')
102 tree_view = custom_page.select_single('GtkTreeView')
103 items = tree_view.get_all_items()
104- print('partition_tree_items')
105- print('-' * 78)
106- for item in items:
107- if item.accessible_name == u'':
108- print('empty item ------------')
109- else:
110- print(item.accessible_name)
111- print('-' * 78)
112-
113- #root = self.get_root_instance()
114- #item = root.select_single('GtkTextCellAccessible',
115- # accessible_name=mountPoint)
116- #item.visible.wait_for(True)
117- #assert item is not None
118+ fsFormat = config['FileSystemType']
119+ mount_point = config['MountPoint']
120+ size_obj = config['PartitionSize']
121+ if mount_point:
122+ index = next((index for index, value in enumerate(items)
123+ if mount_point == value.accessible_name), None)
124+ self.assertIsNotNone(index,
125+ "Could not get index for '{0}' tree item"
126+ .format(mount_point))
127+ logger.debug("Found index for {0} tree item".format(mount_point))
128+ fs_item = tree_view.select_item_by_index(index - 1)
129+ mount_item = tree_view.select_item_by_index(index)
130+ size_item = tree_view.select_item_by_index(index + 1)
131+ else:
132+ index = next((index for index, value in enumerate(items)
133+ if fsFormat.lower() == value.accessible_name), None)
134+ self.assertIsNotNone(index,
135+ "Could not get index for {0} FS tree item"
136+ .format(fsFormat))
137+ logger.debug("Found index for {0} tree item".format(fsFormat))
138+ fs_item = tree_view.select_item_by_index(index)
139+ mount_item = tree_view.select_item_by_index(index + 1)
140+ size_item = tree_view.select_item_by_index(index + 2)
141+
142+ self.expectThat(fsFormat.lower(), Equals(fs_item.accessible_name))
143+ self.expectThat(fs_item.visible, Equals(True),
144+ "[Page: '{0}'] Expected {0} to be visible but "
145+ "it wasn't".format(fs_item.accessible_name))
146+
147+ if mount_point:
148+ # Fail the test if we don't have correct mount point
149+ self.assertThat(mount_point,
150+ Equals(mount_item.accessible_name))
151+ self.expectThat(mount_item.visible, Equals(True),
152+ "[Page: '{0}'] Expected {0} to be visible but "
153+ "it wasn't".format(mount_item.accessible_name))
154+
155+ if size_obj:
156+ self.expectThat(
157+ size_obj, Equals(
158+ int(size_item.accessible_name.strip(' MB'))),
159+ "[Page:'{0}'] Expected partition size to be "
160+ "{1}MB but instead it's {2}.".format(
161+ self.current_step,
162+ str(size_obj),
163+ size_item.accessible_name))
164+ self.expectThat(size_item.visible, Equals(True),
165+ "[Page: '{0}'] Expected {0} to be visible but "
166+ " it wasn't".format(size_item.accessible_name))
167+ logger.debug("Partition created")
168
169 def _check_navigation_buttons(self, continue_button=True, back_button=True,
170 quit_button=True, skip_button=False):
171
172=== removed file 'autopilot/ubiquity_autopilot_tests/tools/_exc.py'
173--- autopilot/ubiquity_autopilot_tests/tools/_exc.py 2013-11-19 09:07:08 +0000
174+++ autopilot/ubiquity_autopilot_tests/tools/_exc.py 1970-01-01 00:00:00 +0000
175@@ -1,6 +0,0 @@
176-__author__ = 'dan'
177-
178-
179-class NonFatalErrors(AssertionError):
180- """ Exception class for raising non fatal errors
181- """

Subscribers

People subscribed via source and target branches

to status/vote changes: