Merge lp:~osomon/notes-app/manually-create-db into lp:notes-app

Proposed by Olivier Tilloy
Status: Rejected
Rejected by: Olivier Tilloy
Proposed branch: lp:~osomon/notes-app/manually-create-db
Merge into: lp:notes-app
Diff against target: 342 lines (+51/-106)
7 files modified
tests/autopilot/notes_app/tests/__init__.py (+28/-50)
tests/autopilot/notes_app/tests/test_create.py (+3/-9)
tests/autopilot/notes_app/tests/test_delete.py (+3/-9)
tests/autopilot/notes_app/tests/test_expand_collapse.py (+3/-9)
tests/autopilot/notes_app/tests/test_images.py (+3/-9)
tests/autopilot/notes_app/tests/test_parts.py (+3/-3)
tests/autopilot/notes_app/tests/test_quit.py (+8/-17)
To merge this branch: bzr merge lp:~osomon/notes-app/manually-create-db
Reviewer Review Type Date Requested Status
Olivier Tilloy Disapprove
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+193097@code.launchpad.net

Commit message

Manually create the notes database before starting tests,
instead of launching the app, quitting it, and launching it again.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/222/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/159
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/153/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/4
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/4
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/4/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/4
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/150
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/159
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/159/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/153
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/153/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2777/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2827/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/594
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/593

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/222/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/223/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/161
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/155/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/5
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/5
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/5/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/5
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/152
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/161
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/161/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/155
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/155/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2779/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2830/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/598
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/597

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/223/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/224/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/163
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/157/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/6
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/6
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/6/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/6
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/154
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/163
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/163/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/157
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/157/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2781/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2832/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/602
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/601

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/224/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/225/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/170
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/164/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/7
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/7
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/7/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/7
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/160
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/170
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/170/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/164
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/164/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2786/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2838/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/611
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/613

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/225/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/226/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/172
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/166/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/8
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/8
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/8/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/8
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/162
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/172
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/172/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/166
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/166/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2789/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2839/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/618
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/616

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/226/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:219
http://jenkins.qa.ubuntu.com/job/notes-app-ci/227/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/176
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/170/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-amd64-ci/9
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/9
        deb: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-armhf-ci/9/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/notes-app-trusty-i386-ci/9
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/165
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/176
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/176/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/170
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/170/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2793/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2844/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/626
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/625

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/notes-app-ci/227/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :
review: Disapprove

Unmerged revisions

219. By Olivier Tilloy

Remove the DatabaseMixin helper class.

218. By Olivier Tilloy

Manually create the notes database before starting tests,
instead of launching the app, quitting it, and launching it again.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/notes_app/tests/__init__.py'
--- tests/autopilot/notes_app/tests/__init__.py 2013-10-08 21:50:29 +0000
+++ tests/autopilot/notes_app/tests/__init__.py 2013-10-29 16:46:19 +0000
@@ -8,10 +8,13 @@
8"""notes-app autopilot tests."""8"""notes-app autopilot tests."""
99
10import BaseHTTPServer10import BaseHTTPServer
11import base64
12import glob
13import md5
14import os
11import os.path15import os.path
12import glob16import sqlite3
13import threading17import threading
14import base64
1518
16from autopilot.input import Mouse, Touch, Pointer19from autopilot.input import Mouse, Touch, Pointer
17from autopilot.matchers import Eventually20from autopilot.matchers import Eventually
@@ -82,17 +85,29 @@
82 "com.ubuntu.notes",85 "com.ubuntu.notes",
83 emulator_base=UbuntuUIToolkitEmulatorBase)86 emulator_base=UbuntuUIToolkitEmulatorBase)
8487
85 def launch_and_quit_app(self):88 def ensure_db(self):
86 self.launch_app()89 path = os.path.expanduser("~/.local/share/com.ubuntu.notes/Databases")
87 self.main_window.visible.wait_for(True)90 if not os.path.exists(path):
8891 os.makedirs(path)
89 # When calling launch_app an instance of the spawned process92 filepath = os.path.join(path, md5.md5("notes").hexdigest())
90 # control object will be stored in self.app.process, and a cleanup93 ini = filepath + ".ini"
91 # handler will be registered that essentially kills the process.94 if not os.path.exists(ini):
92 # Therefore, by triggering the cleanup handler here we're killing the95 with open(ini, "w") as f:
93 # process and removing the handler, which allows a clean launch of96 f.write("""[General]
94 # the process during regular test setup.97Description=Notes database
95 self.doCleanups()98Driver=QSQLITE
99EstimatedSize=3145728
100Name=notes
101Version=1
102""")
103 sql = filepath + ".sqlite"
104 connection = sqlite3.connect(sql)
105 cursor = connection.cursor()
106 cursor.execute("CREATE TABLE IF NOT EXISTS notes "
107 "(id INTEGER PRIMARY KEY, date DATETIME, note TEXT)")
108 connection.commit()
109 connection.close()
110 return sql
96111
97 def assert_osk_eventually_shown(self):112 def assert_osk_eventually_shown(self):
98 if model() != 'Desktop':113 if model() != 'Desktop':
@@ -176,40 +191,3 @@
176 def tearDown(self):191 def tearDown(self):
177 super(NotesTestCaseBaseWithHTTPServer, self).tearDown()192 super(NotesTestCaseBaseWithHTTPServer, self).tearDown()
178 self.server.shutdown()193 self.server.shutdown()
179
180
181class DatabaseMixin(object):
182
183 """
184 Helper functions for dealing with sqlite databases
185 """
186
187 def _get_db_path(self):
188 db_path_list = [
189 "~/.local/share/com.ubuntu.notes/Databases",
190 "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/"
191 "Databases/"]
192 for path in db_path_list:
193 path = os.path.expanduser(path)
194 if os.path.exists(path):
195 return path
196 return None
197
198 def find_db(self):
199 dbs_path = self._get_db_path()
200 if not dbs_path:
201 return None
202 files = [f for f in os.listdir(dbs_path)
203 if os.path.splitext(f)[1] == ".ini"]
204 for f in files:
205 ini_path = os.path.join(dbs_path, f)
206 with open(ini_path) as ini:
207 for line in ini:
208 if "=" in line:
209 key, val = line.strip().split("=")
210 if key == "Name" and val == "notes":
211 try:
212 return ini_path.replace(".ini", ".sqlite")
213 except OSError:
214 pass
215 return None
216194
=== modified file 'tests/autopilot/notes_app/tests/test_create.py'
--- tests/autopilot/notes_app/tests/test_create.py 2013-09-27 14:42:07 +0000
+++ tests/autopilot/notes_app/tests/test_create.py 2013-10-29 16:46:19 +0000
@@ -12,12 +12,12 @@
12from testtools.matchers import Equals12from testtools.matchers import Equals
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from notes_app.tests import NotesAppTestCase, DatabaseMixin15from notes_app.tests import NotesAppTestCase
1616
17import os17import os
1818
1919
20class TestCreate(NotesAppTestCase, DatabaseMixin):20class TestCreate(NotesAppTestCase):
21 """Tests creating notes"""21 """Tests creating notes"""
2222
23 """ This is needed to wait for the application to start.23 """ This is needed to wait for the application to start.
@@ -29,13 +29,7 @@
29 super(TestCreate, self).setUp()29 super(TestCreate, self).setUp()
3030
31 def clean_db(self):31 def clean_db(self):
32 path = self.find_db()32 path = self.ensure_db()
33 if path is None:
34 self.launch_and_quit_app()
35 path = self.find_db()
36 if path is None:
37 self.assertNotEquals(path, None)
38
39 try:33 try:
40 os.remove(path)34 os.remove(path)
41 except OSError:35 except OSError:
4236
=== modified file 'tests/autopilot/notes_app/tests/test_delete.py'
--- tests/autopilot/notes_app/tests/test_delete.py 2013-10-10 09:30:43 +0000
+++ tests/autopilot/notes_app/tests/test_delete.py 2013-10-29 16:46:19 +0000
@@ -12,12 +12,12 @@
12from testtools.matchers import Equals12from testtools.matchers import Equals
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from notes_app.tests import NotesAppTestCase, DatabaseMixin15from notes_app.tests import NotesAppTestCase
1616
17import sqlite317import sqlite3
1818
1919
20class TestDelete(NotesAppTestCase, DatabaseMixin):20class TestDelete(NotesAppTestCase):
21 """Tests deleting notes"""21 """Tests deleting notes"""
2222
23 def setUp(self):23 def setUp(self):
@@ -30,13 +30,7 @@
30 {"content":"This is a note.","type":"text"}30 {"content":"This is a note.","type":"text"}
31 ]}"""31 ]}"""
3232
33 path = self.find_db()33 path = self.ensure_db()
34 if path is None:
35 self.launch_and_quit_app()
36 path = self.find_db()
37 if path is None:
38 self.assertNotEquals(path, None)
39
40 conn = sqlite3.connect(path)34 conn = sqlite3.connect(path)
41 cursor = conn.cursor()35 cursor = conn.cursor()
42 cursor.execute("DELETE FROM notes")36 cursor.execute("DELETE FROM notes")
4337
=== modified file 'tests/autopilot/notes_app/tests/test_expand_collapse.py'
--- tests/autopilot/notes_app/tests/test_expand_collapse.py 2013-10-01 07:42:44 +0000
+++ tests/autopilot/notes_app/tests/test_expand_collapse.py 2013-10-29 16:46:19 +0000
@@ -12,12 +12,12 @@
12from testtools.matchers import Equals12from testtools.matchers import Equals
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from notes_app.tests import NotesAppTestCase, DatabaseMixin15from notes_app.tests import NotesAppTestCase
1616
17import sqlite317import sqlite3
1818
1919
20class TestExpandCollapse(NotesAppTestCase, DatabaseMixin):20class TestExpandCollapse(NotesAppTestCase):
21 """Tests deleting notes"""21 """Tests deleting notes"""
2222
23 def setUp(self):23 def setUp(self):
@@ -35,13 +35,7 @@
35 ]}"""35 ]}"""
36 ]36 ]
3737
38 path = self.find_db()38 path = self.ensure_db()
39 if path is None:
40 self.launch_and_quit_app()
41 path = self.find_db()
42 if path is None:
43 self.assertNotEquals(path, None)
44
45 conn = sqlite3.connect(path)39 conn = sqlite3.connect(path)
46 cursor = conn.cursor()40 cursor = conn.cursor()
47 cursor.execute("DELETE FROM notes")41 cursor.execute("DELETE FROM notes")
4842
=== modified file 'tests/autopilot/notes_app/tests/test_images.py'
--- tests/autopilot/notes_app/tests/test_images.py 2013-10-07 10:10:40 +0000
+++ tests/autopilot/notes_app/tests/test_images.py 2013-10-29 16:46:19 +0000
@@ -12,12 +12,12 @@
12from testtools.matchers import Equals12from testtools.matchers import Equals
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from notes_app.tests import NotesTestCaseBaseWithHTTPServer, DatabaseMixin15from notes_app.tests import NotesTestCaseBaseWithHTTPServer
1616
17import sqlite317import sqlite3
1818
1919
20class BaseForTestImages(NotesTestCaseBaseWithHTTPServer, DatabaseMixin):20class BaseForTestImages(NotesTestCaseBaseWithHTTPServer):
21 def setUp(self):21 def setUp(self):
22 self.setup_db(self.IMAGE)22 self.setup_db(self.IMAGE)
23 super(BaseForTestImages, self).setUp()23 super(BaseForTestImages, self).setUp()
@@ -27,13 +27,7 @@
27 {"content":"http://localhost:8129/""" + image + """","type":"image"}27 {"content":"http://localhost:8129/""" + image + """","type":"image"}
28 ]}"""28 ]}"""
2929
30 path = self.find_db()30 path = self.ensure_db()
31 if path is None:
32 self.launch_and_quit_app()
33 path = self.find_db()
34 if path is None:
35 self.assertNotEquals(path, None)
36
37 conn = sqlite3.connect(path)31 conn = sqlite3.connect(path)
38 cursor = conn.cursor()32 cursor = conn.cursor()
39 cursor.execute("DELETE FROM notes")33 cursor.execute("DELETE FROM notes")
4034
=== modified file 'tests/autopilot/notes_app/tests/test_parts.py'
--- tests/autopilot/notes_app/tests/test_parts.py 2013-10-07 10:21:27 +0000
+++ tests/autopilot/notes_app/tests/test_parts.py 2013-10-29 16:46:19 +0000
@@ -13,12 +13,12 @@
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
14from autopilot.platform import model14from autopilot.platform import model
1515
16from notes_app.tests import NotesTestCaseBaseWithHTTPServer, DatabaseMixin16from notes_app.tests import NotesTestCaseBaseWithHTTPServer
1717
18import sqlite318import sqlite3
1919
2020
21class TestFocus(NotesTestCaseBaseWithHTTPServer, DatabaseMixin):21class TestFocus(NotesTestCaseBaseWithHTTPServer):
22 """Tests focusing notes"""22 """Tests focusing notes"""
2323
24 """ This is needed to wait for the application to start.24 """ This is needed to wait for the application to start.
@@ -34,7 +34,7 @@
34 {"content":"http://localhost:8129/image.png","type":"image"}34 {"content":"http://localhost:8129/image.png","type":"image"}
35 ]}"""35 ]}"""
3636
37 path = self.find_db()37 path = self.ensure_db()
38 conn = sqlite3.connect(path)38 conn = sqlite3.connect(path)
39 cursor = conn.cursor()39 cursor = conn.cursor()
40 cursor.execute("DELETE FROM notes")40 cursor.execute("DELETE FROM notes")
4141
=== modified file 'tests/autopilot/notes_app/tests/test_quit.py'
--- tests/autopilot/notes_app/tests/test_quit.py 2013-10-01 07:42:44 +0000
+++ tests/autopilot/notes_app/tests/test_quit.py 2013-10-29 16:46:19 +0000
@@ -13,7 +13,7 @@
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
14from autopilot.introspection.dbus import StateNotFoundError14from autopilot.introspection.dbus import StateNotFoundError
1515
16from notes_app.tests import NotesAppTestCase, DatabaseMixin16from notes_app.tests import NotesAppTestCase
1717
18import sqlite318import sqlite3
19import json19import json
@@ -47,17 +47,8 @@
47 return True47 return True
48 return False48 return False
4949
50 def get_db_path(self):50
51 path = self.find_db()51class TestQuit(NotesAppTestCase, UtilsMixin):
52 if path is None:
53 self.launch_and_quit_app()
54 path = self.find_db()
55 if path is None:
56 self.assertNotEquals(path, None)
57 return path
58
59
60class TestQuit(NotesAppTestCase, DatabaseMixin, UtilsMixin):
61 """Tests save on quit"""52 """Tests save on quit"""
6253
63 """ This is needed to wait for the application to start.54 """ This is needed to wait for the application to start.
@@ -72,7 +63,7 @@
72 {"content":"foobar","type":"text"}63 {"content":"foobar","type":"text"}
73 ]}"""64 ]}"""
7465
75 path = self.get_db_path()66 path = self.ensure_db()
76 conn = sqlite3.connect(path)67 conn = sqlite3.connect(path)
77 cursor = conn.cursor()68 cursor = conn.cursor()
78 cursor.execute("DELETE FROM notes")69 cursor.execute("DELETE FROM notes")
@@ -92,7 +83,7 @@
9283
93 self.assertThat(self.app_has_quit, Eventually(Equals(True)))84 self.assertThat(self.app_has_quit, Eventually(Equals(True)))
9485
95 path = self.find_db()86 path = self.ensure_db()
96 conn = sqlite3.connect(path)87 conn = sqlite3.connect(path)
97 cursor = conn.cursor()88 cursor = conn.cursor()
9889
@@ -105,7 +96,7 @@
105 self.assertEquals(data["elements"][0]["content"], "foobarxxx")96 self.assertEquals(data["elements"][0]["content"], "foobarxxx")
10697
10798
108class TestQuitNoNote(NotesAppTestCase, DatabaseMixin, UtilsMixin):99class TestQuitNoNote(NotesAppTestCase, UtilsMixin):
109 """Tests save on quit with no notes"""100 """Tests save on quit with no notes"""
110101
111 """ This is needed to wait for the application to start.102 """ This is needed to wait for the application to start.
@@ -116,7 +107,7 @@
116 super(TestQuitNoNote, self).setUp()107 super(TestQuitNoNote, self).setUp()
117108
118 def setup_db(self):109 def setup_db(self):
119 path = self.get_db_path()110 path = self.ensure_db()
120 conn = sqlite3.connect(path)111 conn = sqlite3.connect(path)
121 cursor = conn.cursor()112 cursor = conn.cursor()
122 cursor.execute("DELETE FROM notes")113 cursor.execute("DELETE FROM notes")
@@ -134,7 +125,7 @@
134125
135 self.assertThat(self.app_has_quit, Eventually(Equals(True)))126 self.assertThat(self.app_has_quit, Eventually(Equals(True)))
136127
137 path = self.find_db()128 path = self.ensure_db()
138 conn = sqlite3.connect(path)129 conn = sqlite3.connect(path)
139 cursor = conn.cursor()130 cursor = conn.cursor()
140131

Subscribers

People subscribed via source and target branches