Merge lp://qastaging/~rick-rickspencer3/desktopcouch/couchwidgetfixandtests into lp://qastaging/desktopcouch

Proposed by Rick Spencer
Status: Merged
Approved by: Elliot Murphy
Approved revision: 39
Merged at revision: not available
Proposed branch: lp://qastaging/~rick-rickspencer3/desktopcouch/couchwidgetfixandtests
Merge into: lp://qastaging/desktopcouch
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~rick-rickspencer3/desktopcouch/couchwidgetfixandtests
Reviewer Review Type Date Requested Status
Elliot Murphy (community) Approve
Review via email: mp+10432@code.qastaging.launchpad.net

Commit message

added unit tests for couchwidget, and then fixed bug #412266

To post a comment you must log in.
Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

There are two changes here:
1. I added unit tests for CouchWidget, with two initial tests to ensure that CouchWidget is set up correctly.
2. I fixed bug #41226 - though I suspect there are similar bugs that I will find when I build out the unit tests.

Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

There are two changes here:
1. I added unit tests for CouchWidget, with two initial tests to ensure that CouchWidget is set up correctly.
2. I fixed bug #41226 - though I suspect there are similar bugs that I will find when I build out the unit tests.

Revision history for this message
Elliot Murphy (statik) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'desktopcouch/records/couchwidget.py'
--- desktopcouch/records/couchwidget.py 2009-08-18 23:05:18 +0000
+++ desktopcouch/records/couchwidget.py 2009-08-19 23:01:09 +0000
@@ -67,7 +67,7 @@
67 def headings(self, headings):67 def headings(self, headings):
68 self.__headings = headings68 self.__headings = headings
69 if self.record_type != None:69 if self.record_type != None:
70 self.__populate_treeview()(self.record_type)70 self.__populate_treeview()
7171
72 @property72 @property
73 def editable(self):73 def editable(self):
@@ -119,7 +119,7 @@
119119
120 def __populate_treeview(self):120 def __populate_treeview(self):
121 #if the database is not set up, just return121 #if the database is not set up, just return
122 if self.__db == None:122 if self.__db == None or self.__headings == None:
123 return123 return
124124
125 #refresh the model structure125 #refresh the model structure
126126
=== added file 'desktopcouch/records/tests/test_couchwidget.py'
--- desktopcouch/records/tests/test_couchwidget.py 1970-01-01 00:00:00 +0000
+++ desktopcouch/records/tests/test_couchwidget.py 2009-08-19 23:01:09 +0000
@@ -0,0 +1,94 @@
1# Copyright 2009 Canonical Ltd.
2#
3# This file is part of desktopcouch.
4#
5# desktopcouch is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License version 3
7# as published by the Free Software Foundation.
8#
9# desktopcouch is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with desktopcouch. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authors: Rick Spencer <rick.spencer@canonical.com>
18
19"""Tests for the couchwidget object"""
20
21from testtools import TestCase
22from desktopcouch.records.server import CouchDatabase
23from desktopcouch.records.couchwidget import CouchWidget
24
25class TestCouchWidget(TestCase):
26 """Test the CouchWidget functionality"""
27 def setUp(self):
28 self.dbname = "couch_widget_test"
29 self.record_type = "test_record_type"
30
31 def test_headings_first(self):
32 #create a test widget with test database values
33 cw = CouchWidget()
34 cw.database = self.dbname
35
36 #allow editing
37 cw.editable = True
38
39 #create headers/keys
40 cw.headings = ["Key1","Key2","Key3","Key4"]
41
42 #set the record_type for the TreeView
43 #it will not populate without this value being set
44 cw.record_type = self.record_type
45
46 #create a row with all four columns set
47 cw.append_row(["val1","val2","val3","val4"])
48
49 #create a row with only the second column set
50 cw.append_row(["","val2"])
51
52 #create an empty row (which will not be saved until the user edits it)
53 cw.append_row([])
54
55 self.assertEqual(cw.record_type, self.record_type)
56 self.__delete_db()
57
58 def test_record_type_first(self):
59 #create a test widget with test database values
60 cw = CouchWidget()
61 cw.database = self.dbname
62
63 #allow editing
64 cw.editable = True
65
66 #set the record_type for the TreeView
67 #it will not populate without this value being set
68 cw.record_type = self.record_type
69
70 #create headers/keys
71 cw.headings = ["Key1","Key2","Key3","Key4"]
72
73 #create a row with all four columns set
74 cw.append_row(["val1","val2","val3","val4"])
75
76 #create a row with only the second column set
77 cw.append_row(["","val2"])
78
79 #create an empty row (which will not be saved until the user edits it)
80 cw.append_row([])
81
82 self.assertEqual(cw.record_type, self.record_type)
83 self.__delete_db()
84
85 def tearDown(self):
86 """tear down each test"""
87 self.__delete_db()
88 #delete the database
89
90 def __delete_db(self):
91 db = CouchDatabase(self.dbname, create=True)
92 del db._server[self.dbname]
93
94

Subscribers

People subscribed via source and target branches