Merge lp:~nskaggs/ubuntu-calculator-app/fix-db-path into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 175
Merged at revision: 173
Proposed branch: lp:~nskaggs/ubuntu-calculator-app/fix-db-path
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 99 lines (+27/-36)
1 file modified
tests/autopilot/ubuntu_calculator_app/tests/__init__.py (+27/-36)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calculator-app/fix-db-path
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+189141@code.launchpad.net

Commit message

update the hardcoded db path so autopilot tests can continue to work

Description of the change

Fix https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1234544, update the hardcoded db path so autopilot tests can continue to work

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
174. By Nicholas Skaggs

add logging needs

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
175. By Nicholas Skaggs

fix pyflakes errors

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Thanks Nicholas, works great for me!

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

It would have been better not to hardcode the new DB pathname... Now these tests may only run with the updated SDK, not the "old" one which means they need to land together.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/__init__.py'
--- tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-09-30 06:39:24 +0000
+++ tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-10-03 19:15:12 +0000
@@ -9,16 +9,17 @@
99
10import os10import os
11import shutil11import shutil
12import logging
1213
13from autopilot.input import Mouse, Touch, Pointer14from autopilot.input import Mouse, Touch, Pointer
14from autopilot.matchers import Eventually
15from autopilot.platform import model15from autopilot.platform import model
16from autopilot.testcase import AutopilotTestCase16from autopilot.testcase import AutopilotTestCase
17from testtools.matchers import Equals
18from ubuntuuitoolkit import emulators as toolkit_emulators17from ubuntuuitoolkit import emulators as toolkit_emulators
1918
20from ubuntu_calculator_app import emulators19from ubuntu_calculator_app import emulators
2120
21logger = logging.getLogger(__name__)
22
2223
23class CalculatorTestCase(AutopilotTestCase):24class CalculatorTestCase(AutopilotTestCase):
2425
@@ -36,7 +37,7 @@
36 "ubuntu-calculator-app.qml"37 "ubuntu-calculator-app.qml"
3738
38 sqlite_dir = os.path.expanduser(39 sqlite_dir = os.path.expanduser(
39 "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")40 "~/.local/share/ubuntu-calculator-app/Databases")
40 backup_dir = sqlite_dir + ".backup"41 backup_dir = sqlite_dir + ".backup"
4142
42 def setUp(self):43 def setUp(self):
@@ -74,43 +75,33 @@
74 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)75 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
7576
76 def temp_move_sqlite_db(self):77 def temp_move_sqlite_db(self):
77 if os.path.exists(self.sqlite_dir) and os.path.exists(self.backup_dir):78 try:
78 # In case the test suite was interrupted (ctrl+c) it may not run
79 # again because there is already a backup dir, so we make sure to
80 # delete it.
81 shutil.rmtree(self.backup_dir)79 shutil.rmtree(self.backup_dir)
82 self.assertThat(80 except:
83 lambda: os.path.exists(self.backup_dir),
84 Eventually(Equals(False)))
85 shutil.move(self.sqlite_dir, self.backup_dir)
86 self.assertThat(
87 lambda: os.path.exists(self.backup_dir),
88 Eventually(Equals(True)))
89 elif os.path.exists(self.sqlite_dir):
90 shutil.move(self.sqlite_dir, self.backup_dir)
91 self.assertThat(
92 lambda: os.path.exists(self.backup_dir),
93 Eventually(Equals(True)))
94 else:
95 pass81 pass
82 else:
83 logger.warning("Prexisting backup database found and removed")
84
85 try:
86 shutil.move(self.sqlite_dir, self.backup_dir)
87 except:
88 logger.warning("No current database found")
89 else:
90 logger.debug("Backed up database")
9691
97 def restore_sqlite_db(self):92 def restore_sqlite_db(self):
98 if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):93 if os.path.exists(self.backup_dir):
99 shutil.rmtree(self.sqlite_dir)94 if os.path.exists(self.sqlite_dir):
100 self.assertThat(95 try:
101 lambda: os.path.exists(self.sqlite_dir),96 shutil.rmtree(self.sqlite_dir)
102 Eventually(Equals(False)))97 except:
103 shutil.move(self.backup_dir, self.sqlite_dir)98 logger.error("Failed to remove test database and restore" /
104 self.assertTrue(99 "database")
105 lambda: os.path.exists(self.sqlite_dir),100 return
106 Eventually(Equals(True)))101 try:
107 elif os.path.exists(self.backup_dir):102 shutil.move(self.backup_dir, self.sqlite_dir)
108 shutil.move(self.backup_dir, self.sqlite_dir)103 except:
109 self.assertTrue(104 logger.error("Failed to restore database")
110 lambda: os.path.exists(self.sqlite_dir),
111 Eventually(Equals(True)))
112 else:
113 pass
114105
115 @property106 @property
116 def main_view(self):107 def main_view(self):

Subscribers

People subscribed via source and target branches