Merge lp://qastaging/~cmiller/desktopcouch/test-coverage into lp://qastaging/desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 98
Merged at revision: not available
Proposed branch: lp://qastaging/~cmiller/desktopcouch/test-coverage
Merge into: lp://qastaging/desktopcouch
Diff against target: 121 lines (+46/-3)
3 files modified
desktopcouch/records/tests/test_record.py (+22/-1)
desktopcouch/records/tests/test_server.py (+8/-1)
desktopcouch/tests/test_local_files.py (+16/-1)
To merge this branch: bzr merge lp://qastaging/~cmiller/desktopcouch/test-coverage
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Nicola Larosa (community) Approve
Review via email: mp+14968@code.qastaging.launchpad.net

Commit message

Add tests to exercise some code that is previously neglected by tests.

To post a comment you must log in.
Revision history for this message
Nicola Larosa (teknico) wrote :

Again, can we write down somewhere how to run tests on desktopcouch? Thanks.

review: Abstain
Revision history for this message
Nicola Larosa (teknico) wrote :

> Again, can we write down somewhere how to run tests on desktopcouch? Thanks.

And again, it was "trial desktopcouch", sorry for the blackout.

Revision history for this message
Nicola Larosa (teknico) wrote :

Tests pass, more tests is good, all is well.

review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Awesome branch!

test_bind_address asks me for access to the keyring, not sure whether that's a problem in this case? Approved, but I'll be available for retesting if this needs to be fixed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'desktopcouch/records/tests/test_record.py'
--- desktopcouch/records/tests/test_record.py 2009-10-02 23:47:26 +0000
+++ desktopcouch/records/tests/test_record.py 2009-11-17 22:45:25 +0000
@@ -24,7 +24,7 @@
24# pylint does not like relative imports from containing packages24# pylint does not like relative imports from containing packages
25# pylint: disable-msg=F040125# pylint: disable-msg=F0401
26from desktopcouch.records.record import (Record, RecordDict, MergeableList,26from desktopcouch.records.record import (Record, RecordDict, MergeableList,
27 record_factory, IllegalKeyException, validate)27 record_factory, IllegalKeyException, validate, NoRecordTypeSpecified)
2828
2929
30class TestRecords(TestCase):30class TestRecords(TestCase):
@@ -51,6 +51,25 @@
51 }51 }
52 self.record = Record(self.dict)52 self.record = Record(self.dict)
5353
54 def test_delitem(self):
55 def f(r):
56 del r["_id"]
57 self.assertRaises(KeyError, f, self.record)
58
59 del self.record["a"]
60
61 def test_iter(self):
62 self.assertEquals(sorted(list(iter(self.record))),
63 ['a', 'b', 'record_type', 'subfield', 'subfield_uuid'])
64
65 def test_setitem_internal(self):
66 def f(r):
67 r["_id"] = "new!"
68 self.assertRaises(IllegalKeyException, f, self.record)
69
70 def test_no_record_type(self):
71 self.assertRaises(NoRecordTypeSpecified, Record, {})
72
54 def test_get_item(self):73 def test_get_item(self):
55 "Does a RecordDict basically wrap a dict properly?"74 "Does a RecordDict basically wrap a dict properly?"
56 self.assertEqual(self.dict["a"], self.record["a"])75 self.assertEqual(self.dict["a"], self.record["a"])
@@ -67,6 +86,8 @@
67 self.assertEqual(86 self.assertEqual(
68 ['a', 'b', 'record_type', 'subfield', 'subfield_uuid'],87 ['a', 'b', 'record_type', 'subfield', 'subfield_uuid'],
69 sorted(self.record.keys()))88 sorted(self.record.keys()))
89 self.assertIn("a", self.record)
90 self.assertNotIn("_id", self.record) # is internal. play dumb.
7091
71 def test_application_annotations(self):92 def test_application_annotations(self):
72 """Test getting application specific data."""93 """Test getting application specific data."""
7394
=== modified file 'desktopcouch/records/tests/test_server.py'
--- desktopcouch/records/tests/test_server.py 2009-11-17 17:07:41 +0000
+++ desktopcouch/records/tests/test_server.py 2009-11-17 22:45:25 +0000
@@ -21,7 +21,7 @@
2121
22from desktopcouch.tests import xdg_cache22from desktopcouch.tests import xdg_cache
23from desktopcouch.records.server import CouchDatabase23from desktopcouch.records.server import CouchDatabase
24from desktopcouch.records.server_base import row_is_deleted24from desktopcouch.records.server_base import row_is_deleted, NoSuchDatabase
25from desktopcouch.records.record import Record25from desktopcouch.records.record import Record
2626
27FAKE_RECORD_TYPE = "http://example.org/test"27FAKE_RECORD_TYPE = "http://example.org/test"
@@ -59,6 +59,9 @@
59 """tear down each test"""59 """tear down each test"""
60 del self.database._server[self.dbname]60 del self.database._server[self.dbname]
6161
62 def test_database_not_exists(self):
63 self.assertRaises(NoSuchDatabase, CouchDatabase, "this-must-not-exist", create=False)
64
62 def test_get_records_by_record_type_save_view(self):65 def test_get_records_by_record_type_save_view(self):
63 """Test getting mutliple records by type"""66 """Test getting mutliple records by type"""
64 records = self.database.get_records(67 records = self.database.get_records(
@@ -100,6 +103,7 @@
100 def test_record_exists(self):103 def test_record_exists(self):
101 """Test checking whether a record exists."""104 """Test checking whether a record exists."""
102 record = Record({'record_number': 0}, record_type="http://example.com/")105 record = Record({'record_number': 0}, record_type="http://example.com/")
106 self.assert_(not self.database.record_exists("ThisMustNotExist"))
103 record_id = self.database.put_record(record)107 record_id = self.database.put_record(record)
104 self.assert_(self.database.record_exists(record_id))108 self.assert_(self.database.record_exists(record_id))
105 self.database.delete_record(record_id)109 self.database.delete_record(record_id)
@@ -179,6 +183,9 @@
179183
180 self.assertTrue(len(record_ids_we_care_about) == 0, "expected zero")184 self.assertTrue(len(record_ids_we_care_about) == 0, "expected zero")
181185
186 self.assertRaises(KeyError, self.database.get_records,
187 design_doc="mustNotExist", create_view=False)
188
182 def test_list_views(self):189 def test_list_views(self):
183 design_doc = "d"190 design_doc = "d"
184 self.assertEqual(self.database.list_views(design_doc), [])191 self.assertEqual(self.database.list_views(design_doc), [])
185192
=== modified file 'desktopcouch/tests/test_local_files.py'
--- desktopcouch/tests/test_local_files.py 2009-09-14 15:56:42 +0000
+++ desktopcouch/tests/test_local_files.py 2009-11-17 22:45:25 +0000
@@ -1,8 +1,9 @@
1"""testing desktopcouch/local_files.py module"""1"""testing desktopcouch/local_files.py module"""
22
3import testtools3import testtools
4from desktopcouch.tests import xdg_cache4import desktopcouch.tests
5import desktopcouch5import desktopcouch
6import os
67
7class TestLocalFiles(testtools.TestCase):8class TestLocalFiles(testtools.TestCase):
8 """Testing that local files returns the right things"""9 """Testing that local files returns the right things"""
@@ -25,3 +26,17 @@
25 if x.endswith("compulsory-auth.ini")]26 if x.endswith("compulsory-auth.ini")]
26 self.assertTrue(len(ok) > 0)27 self.assertTrue(len(ok) > 0)
2728
29 def test_bind_address(self):
30 desktopcouch.start_local_couchdb.create_ini_file()
31 desktopcouch.start_local_couchdb.create_ini_file() # Make sure the loader works.
32
33 old = desktopcouch.local_files.get_bind_address()
34 octets = old.split(".")
35 octets[2] = str((int(octets[2]) + 128) % 256)
36 new = ".".join(octets)
37 desktopcouch.local_files.set_bind_address(new)
38
39 self.assertEquals(desktopcouch.local_files.get_bind_address(), new)
40 desktopcouch.local_files.set_bind_address(old)
41 self.assertEquals(desktopcouch.local_files.get_bind_address(), old)
42

Subscribers

People subscribed via source and target branches