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
1=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/__init__.py'
2--- tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-09-30 06:39:24 +0000
3+++ tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-10-03 19:15:12 +0000
4@@ -9,16 +9,17 @@
5
6 import os
7 import shutil
8+import logging
9
10 from autopilot.input import Mouse, Touch, Pointer
11-from autopilot.matchers import Eventually
12 from autopilot.platform import model
13 from autopilot.testcase import AutopilotTestCase
14-from testtools.matchers import Equals
15 from ubuntuuitoolkit import emulators as toolkit_emulators
16
17 from ubuntu_calculator_app import emulators
18
19+logger = logging.getLogger(__name__)
20+
21
22 class CalculatorTestCase(AutopilotTestCase):
23
24@@ -36,7 +37,7 @@
25 "ubuntu-calculator-app.qml"
26
27 sqlite_dir = os.path.expanduser(
28- "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")
29+ "~/.local/share/ubuntu-calculator-app/Databases")
30 backup_dir = sqlite_dir + ".backup"
31
32 def setUp(self):
33@@ -74,43 +75,33 @@
34 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
35
36 def temp_move_sqlite_db(self):
37- if os.path.exists(self.sqlite_dir) and os.path.exists(self.backup_dir):
38- # In case the test suite was interrupted (ctrl+c) it may not run
39- # again because there is already a backup dir, so we make sure to
40- # delete it.
41+ try:
42 shutil.rmtree(self.backup_dir)
43- self.assertThat(
44- lambda: os.path.exists(self.backup_dir),
45- Eventually(Equals(False)))
46- shutil.move(self.sqlite_dir, self.backup_dir)
47- self.assertThat(
48- lambda: os.path.exists(self.backup_dir),
49- Eventually(Equals(True)))
50- elif os.path.exists(self.sqlite_dir):
51- shutil.move(self.sqlite_dir, self.backup_dir)
52- self.assertThat(
53- lambda: os.path.exists(self.backup_dir),
54- Eventually(Equals(True)))
55- else:
56+ except:
57 pass
58+ else:
59+ logger.warning("Prexisting backup database found and removed")
60+
61+ try:
62+ shutil.move(self.sqlite_dir, self.backup_dir)
63+ except:
64+ logger.warning("No current database found")
65+ else:
66+ logger.debug("Backed up database")
67
68 def restore_sqlite_db(self):
69- if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
70- shutil.rmtree(self.sqlite_dir)
71- self.assertThat(
72- lambda: os.path.exists(self.sqlite_dir),
73- Eventually(Equals(False)))
74- shutil.move(self.backup_dir, self.sqlite_dir)
75- self.assertTrue(
76- lambda: os.path.exists(self.sqlite_dir),
77- Eventually(Equals(True)))
78- elif os.path.exists(self.backup_dir):
79- shutil.move(self.backup_dir, self.sqlite_dir)
80- self.assertTrue(
81- lambda: os.path.exists(self.sqlite_dir),
82- Eventually(Equals(True)))
83- else:
84- pass
85+ if os.path.exists(self.backup_dir):
86+ if os.path.exists(self.sqlite_dir):
87+ try:
88+ shutil.rmtree(self.sqlite_dir)
89+ except:
90+ logger.error("Failed to remove test database and restore" /
91+ "database")
92+ return
93+ try:
94+ shutil.move(self.backup_dir, self.sqlite_dir)
95+ except:
96+ logger.error("Failed to restore database")
97
98 @property
99 def main_view(self):

Subscribers

People subscribed via source and target branches