Merge lp:~om26er/ubuntu-weather-app/fix_db_tests into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Omer Akram on 2013-12-17
Status: Rejected
Rejected by: Nicholas Skaggs on 2014-02-13
Proposed branch: lp:~om26er/ubuntu-weather-app/fix_db_tests
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 55 lines (+23/-4)
2 files modified
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+22/-0)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+1/-4)
To merge this branch: bzr merge lp:~om26er/ubuntu-weather-app/fix_db_tests
Reviewer Review Type Date Requested Status
Sergio Schvezov (community) Abstain on 2013-12-17
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2013-12-17
Alan Pope 🍺🐧🐱 πŸ¦„ 2013-12-17 Approve on 2013-12-17
Review via email: mp+199278@code.launchpad.net

Commit message

make sure there is a local database before running the MainWindow tests

To post a comment you must log in.

Tests all pass here.

Ran 15 tests in 405.218s
OK

review: Approve
Sergio Schvezov (sergiusens) wrote :

Instead of waiting for
10 + self.main_window.visible.wait_for(True)

why not wait for the database file you care about to be created? If the app is responsible, the app being visible does not guarantee it has created the db

review: Needs Fixing
169. By Omer Akram on 2013-12-17

don't wait for the app window to appear, rather wait for the database to be created

170. By Omer Akram on 2013-12-17

import md5

review: Approve
review: Abstain
Nicholas Skaggs (nskaggs) wrote :

I believe this is no longer relevant.

Unmerged revisions

170. By Omer Akram on 2013-12-17

import md5

169. By Omer Akram on 2013-12-17

don't wait for the app window to appear, rather wait for the database to be created

168. By Omer Akram on 2013-12-17

make sure we have a db before running tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
2--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-13 15:30:46 +0000
3+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-17 14:44:53 +0000
4@@ -14,6 +14,7 @@
5 import sqlite3
6 import time
7 import logging
8+import md5
9
10 from autopilot.input import Mouse, Touch, Pointer
11 from autopilot.platform import model
12@@ -83,6 +84,27 @@
13 "com.ubuntu.weather",
14 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
15
16+ def launch_and_quit_app(self, database):
17+ self.launch_app()
18+ self.assertThat(
19+ lambda: os.path.exists(database),
20+ Eventually(Equals(True))
21+ )
22+
23+ # When calling launch_app an instance of the spawned process
24+ # control object will be stored in self.app.process, and a cleanup
25+ # handler will be registered that essentially kills the process.
26+ # Therefore, by triggering the cleanup handler here we're killing the
27+ # process and removing the handler, which allows a clean launch of
28+ # the process during regular test setup.
29+ self.doCleanups()
30+
31+ def ensure_db(self):
32+ path = os.path.expanduser("~/.local/share/com.ubuntu.weather/Databases")
33+ db = os.path.join(path, md5.md5("com.ubuntu.weather").hexdigest() + ".sqlite")
34+ if not os.path.exists(db):
35+ self.launch_and_quit_app(db)
36+
37 def get_qml_view(self):
38 return self.app.select_single("QQuickView")
39
40
41=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
42--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-12-11 20:24:42 +0000
43+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-12-17 14:44:53 +0000
44@@ -27,10 +27,7 @@
45 """ This is needed to wait for the application to start.
46 In the testfarm, the application may take some time to show up."""
47 def setUp(self):
48- #close app
49- #logger.debug("Closing app")
50- #self.doCleanups()
51- #wipe the existing database and create a new blank one
52+ self.ensure_db()
53 self.create_blank_db()
54 # add settings to storage
55 logger.debug("Adding fake data to new database")

Subscribers

People subscribed via source and target branches