Merge lp:~om26er/ubuntu-calculator-app/calculator-jenkins-fix into lp:~boiko/ubuntu-calculator-app/fix_autopilot_tests

Proposed by Omer Akram
Status: Merged
Merged at revision: 147
Proposed branch: lp:~om26er/ubuntu-calculator-app/calculator-jenkins-fix
Merge into: lp:~boiko/ubuntu-calculator-app/fix_autopilot_tests
Diff against target: 67 lines (+35/-1)
1 file modified
tests/autopilot/ubuntu_calculator_app/tests/__init__.py (+35/-1)
To merge this branch: bzr merge lp:~om26er/ubuntu-calculator-app/calculator-jenkins-fix
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko Pending
Review via email: mp+181879@code.launchpad.net

Commit message

hopefully fixes autopilot tests in jenkins

Description of the change

hopefully fixes autopilot tests in jenkins

To post a comment you must log in.
148. By Omer Akram

pep8 complaint fix

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-08-08 08:24:24 +0000
3+++ tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-08-23 17:33:25 +0000
4@@ -7,11 +7,14 @@
5
6 """Calculator autopilot tests."""
7
8-import os.path
9+import os
10+import shutil
11
12 from autopilot.input import Mouse, Touch, Pointer
13+from autopilot.matchers import Eventually
14 from autopilot.platform import model
15 from autopilot.testcase import AutopilotTestCase
16+from testtools.matchers import Equals
17 from ubuntuuitoolkit import emulators as toolkit_emulators
18
19 from ubuntu_calculator_app import emulators
20@@ -30,9 +33,15 @@
21
22 local_location = "../../ubuntu-calculator-app.qml"
23
24+ sqlite_dir = os.path.expanduser(
25+ "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")
26+ backup_dir = sqlite_dir + ".backup"
27+
28 def setUp(self):
29 self.pointing_device = Pointer(self.input_device_class.create())
30 super(CalculatorTestCase, self).setUp()
31+ self.temp_move_sqlite_db()
32+ self.addCleanup(self.restore_sqlite_db)
33
34 if os.path.exists(self.local_location):
35 self.launch_test_local()
36@@ -55,6 +64,31 @@
37 app_type='qt',
38 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
39
40+ def temp_move_sqlite_db(self):
41+ if os.path.exists(self.sqlite_dir):
42+ shutil.move(self.sqlite_dir, self.backup_dir)
43+ self.assertThat(
44+ lambda: os.path.exists(self.backup_dir),
45+ Eventually(Equals(True)))
46+
47+ def restore_sqlite_db(self):
48+ if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
49+ shutil.rmtree(self.sqlite_dir)
50+ self.assertThat(
51+ lambda: os.path.exists(self.sqlite_dir),
52+ Eventually(Equals(False)))
53+ shutil.move(self.backup_dir, self.sqlite_dir)
54+ self.assertTrue(
55+ lambda: os.path.exists(self.sqlite_dir),
56+ Eventually(Equals(True)))
57+ elif os.path.exists(self.backup_dir):
58+ shutil.move(self.backup_dir, self.sqlite_dir)
59+ self.assertTrue(
60+ lambda: os.path.exists(self.sqlite_dir),
61+ Eventually(Equals(True)))
62+ else:
63+ pass
64+
65 @property
66 def main_view(self):
67 return self.app.select_single(emulators.MainView)

Subscribers

People subscribed via source and target branches