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

Proposed by Omer Akram
Status: Superseded
Proposed branch: lp:~om26er/ubuntu-weather-app/db_stab2
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 62 lines (+22/-4)
3 files modified
tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.ini (+6/-0)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+15/-0)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+1/-4)
To merge this branch: bzr merge lp:~om26er/ubuntu-weather-app/db_stab2
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Sergio Schvezov (community) Needs Fixing
Ubuntu Weather Developers Pending
Review via email: mp+199321@code.launchpad.net

This proposal has been superseded by a proposal from 2013-12-17.

Commit message

use an archived db for mainview tests

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

for readability I would prefer path.join to be used here
34 + db_path = os.path.expanduser(db_dir + db_file)

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

37 + subprocess.check_call([
38 + "mkdir",
39 + "-p",
40 + "~/.local/share/com.ubuntu.weather/"])

why aren't you usig os.makedirs?

review: Needs Fixing
170. By Omer Akram

database with a big D

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

32 + db_dir = "~/.local/share/com.ubuntu.weather/Databases/"
33 + db_file = "34e1e542f2f083ff18f537b07a380071.sqlite"
34 + db_path = os.path.expanduser(db_dir + db_file)
35 +
36 + if not os.path.exists(db_path):
37 + subprocess.check_call([
38 + "mkdir",
39 + "-p",
        You need the module path
40 + "~/.local/share/com.ubuntu.weather/"])
41 + shutil.copytree("ubuntu_weather_app/databases/", db_dir)

Approximation...
db_dir = "~/.local/share/com.ubuntu.weather/Databases/"
db_file = "34e1e542f2f083ff18f537b07a380071.sqlite"
db_path = os.path.join(os.path.expanduser(db_dir, db_file))
if not os.path.exists(db_path):
    # it's what we want
    os.makedirs(db_dir)
    # you'll need the python module location
    shutil.copytree("ubuntu_weather_app/Databases/", db_dir)

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
171. By Omer Akram

fix per suggests

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
Nicholas Skaggs (nskaggs) wrote :

Any concerns about the relative copy?

shutil.copytree("ubuntu_weather_app/Databases/", db_dir)

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Runs on my mako with and without existing db

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Personally I would of done something closer to (only one hardcoded path)

=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-17 17:09:10 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-17 17:25:10 +0000
@@ -89,13 +89,14 @@
         return self.app.select_single("QQuickView")

     def ensure_db(self):
- db_dir = "~/.local/share/com.ubuntu.weather/Databases/"
+ weather_dir = os.path.expanduser(
+ "~/.local/share/com.ubuntu.weather")
+ db_dir = os.path.join(weather_dir, 'Databases')
         db_file = "34e1e542f2f083ff18f537b07a380071.sqlite"
- abs_path = os.path.expanduser(db_dir)
- db_path = os.path.join(abs_path, db_file)
+ db_path = os.path.join(db_dir, db_file)

         if not os.path.exists(db_path):
- os.makedirs(os.path.expanduser("~/.local/share/com.ubuntu.weather"))
+ os.makedirs(weather_dir)
             shutil.copytree("ubuntu_weather_app/Databases/", db_dir)
             self.assertThat(
                 lambda: os.path.exists(db_path),

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

And for the module path you'll need something like

        database_tmpl_dir = os.path.join(os.path.dirname(ubuntu_weather_app.__file__),
                                   'Databases')

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I agree with Sergio. Should be more robust that way. Thanks Sergio!

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I would also add a logger line saying you are creating the database when you do it :-)

172. By Omer Akram

fix this fraking thing

173. By Omer Akram

fix per sergio' suggestions

Revision history for this message
Omer Akram (om26er) wrote :

Not creating the dir in the test code. shutil.copytree calls makedirs so no need.

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: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

173. By Omer Akram

fix per sergio' suggestions

172. By Omer Akram

fix this fraking thing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'tests/autopilot/ubuntu_weather_app/Databases'
=== added file 'tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.ini'
--- tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.ini 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.ini 2013-12-17 17:48:43 +0000
@@ -0,0 +1,6 @@
1[General]
2Description=Default Ubuntu weather app
3Driver=QSQLITE
4EstimatedSize=100000
5Name=com.ubuntu.weather
6Version=0.3
07
=== added file 'tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.sqlite'
1Binary files tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.sqlite 1970-01-01 00:00:00 +0000 and tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.sqlite 2013-12-17 17:48:43 +0000 differ8Binary files tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.sqlite 1970-01-01 00:00:00 +0000 and tests/autopilot/ubuntu_weather_app/Databases/34e1e542f2f083ff18f537b07a380071.sqlite 2013-12-17 17:48:43 +0000 differ
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-13 15:30:46 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-12-17 17:48:43 +0000
@@ -14,6 +14,7 @@
14import sqlite314import sqlite3
15import time15import time
16import logging16import logging
17import shutil
1718
18from autopilot.input import Mouse, Touch, Pointer19from autopilot.input import Mouse, Touch, Pointer
19from autopilot.platform import model20from autopilot.platform import model
@@ -86,6 +87,20 @@
86 def get_qml_view(self):87 def get_qml_view(self):
87 return self.app.select_single("QQuickView")88 return self.app.select_single("QQuickView")
8889
90 def ensure_db(self):
91 logger.debug("moving the test database")
92 weather_dir = os.path.expanduser(
93 "~/.local/share/com.ubuntu.weather")
94 db_dir = os.path.join(weather_dir, 'Databases')
95 db_file = "34e1e542f2f083ff18f537b07a380071.sqlite"
96 db_path = os.path.join(db_dir, db_file)
97
98 if not os.path.exists(db_path):
99 shutil.copytree("ubuntu_weather_app/Databases", db_dir)
100 self.assertThat(
101 lambda: os.path.exists(db_path),
102 Eventually(Equals(True)))
103
89 @property104 @property
90 def main_window(self):105 def main_window(self):
91 return self.app.select_single(MainView)106 return self.app.select_single(MainView)
92107
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-12-11 20:24:42 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-12-17 17:48:43 +0000
@@ -27,10 +27,7 @@
27 """ This is needed to wait for the application to start.27 """ This is needed to wait for the application to start.
28 In the testfarm, the application may take some time to show up."""28 In the testfarm, the application may take some time to show up."""
29 def setUp(self):29 def setUp(self):
30 #close app30 self.ensure_db()
31 #logger.debug("Closing app")
32 #self.doCleanups()
33 #wipe the existing database and create a new blank one
34 self.create_blank_db()31 self.create_blank_db()
35 # add settings to storage32 # add settings to storage
36 logger.debug("Adding fake data to new database")33 logger.debug("Adding fake data to new database")

Subscribers

People subscribed via source and target branches