Merge lp:~thisfred/u1db/mapping-test-improvements into lp:u1db

Proposed by Eric Casteleijn on 2012-04-16
Status: Merged
Approved by: John A Meinel on 2012-04-16
Approved revision: 256
Merged at revision: 245
Proposed branch: lp:~thisfred/u1db/mapping-test-improvements
Merge into: lp:u1db
Diff against target: 61 lines (+30/-2)
1 file modified
u1db/tests/test_backends.py (+30/-2)
To merge this branch: bzr merge lp:~thisfred/u1db/mapping-test-improvements
Reviewer Review Type Date Requested Status
John A Meinel (community) 2012-04-16 Approve on 2012-04-16
Review via email: mp+102141@code.launchpad.net

Description of the Change

Added a few tests for edge cases, but mostly the tests and the code seem to be in pretty good shape.

To post a comment you must log in.
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 4/16/2012 6:28 PM, Eric Casteleijn wrote:
> Eric Casteleijn has proposed merging
> lp:~thisfred/u1db/mapping-test-improvements into lp:u1db.
>
> Requested reviews: Ubuntu One hackers (ubuntuone-hackers)
>
> For more details, see:
> https://code.launchpad.net/~thisfred/u1db/mapping-test-improvements/+merge/102141
>
> Added a few tests for edge cases, but mostly the tests and the
> code seem to be in pretty good shape.

 merge: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+MbXwACgkQJdeBCYSNAAMNmACgtHZY02qdRY4YjfhPpIU7w74j
FYcAn0YadAyTHRMh/ewZQVTg4JROF5HE
=2xIj
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/tests/test_backends.py'
2--- u1db/tests/test_backends.py 2012-04-09 18:59:28 +0000
3+++ u1db/tests/test_backends.py 2012-04-16 16:27:27 +0000
4@@ -31,7 +31,7 @@
5 )
6
7 from u1db.remote import (
8- http_database
9+ http_database,
10 )
11
12 try:
13@@ -767,13 +767,20 @@
14 self.db.create_index('test-idx', ['sub.foo.bar.baz.qux.fnord'])
15 self.assertEqual([], self.db.get_from_index('test-idx', [('*',)]))
16
17- def test_index_list(self):
18+ def test_index_list1(self):
19 self.db.create_index("index", ["name"])
20 content = '{"name": ["foo", "bar"]}'
21 doc = self.db.create_doc(content)
22 rows = self.db.get_from_index("index", [("bar", )])
23 self.assertEqual([doc], rows)
24
25+ def test_index_list2(self):
26+ self.db.create_index("index", ["name"])
27+ content = '{"name": ["foo", "bar"]}'
28+ doc = self.db.create_doc(content)
29+ rows = self.db.get_from_index("index", [("foo", )])
30+ self.assertEqual([doc], rows)
31+
32 def test_get_from_index_case_sensitive(self):
33 self.db.create_index('test-idx', ['key'])
34 doc1 = self.db.create_doc(simple_doc)
35@@ -857,6 +864,27 @@
36 rows = self.db.get_from_index("index", [("foo", )])
37 self.assertEqual([doc], rows)
38
39+ def test_index_split_words_double_space(self):
40+ self.db.create_index("index", ["split_words(name)"])
41+ content = '{"name": "foo bar"}'
42+ doc = self.db.create_doc(content)
43+ rows = self.db.get_from_index("index", [("bar", )])
44+ self.assertEqual([doc], rows)
45+
46+ def test_index_split_words_leading_space(self):
47+ self.db.create_index("index", ["split_words(name)"])
48+ content = '{"name": " foo bar"}'
49+ doc = self.db.create_doc(content)
50+ rows = self.db.get_from_index("index", [("foo", )])
51+ self.assertEqual([doc], rows)
52+
53+ def test_index_split_words_trailing_space(self):
54+ self.db.create_index("index", ["split_words(name)"])
55+ content = '{"name": "foo bar "}'
56+ doc = self.db.create_doc(content)
57+ rows = self.db.get_from_index("index", [("bar", )])
58+ self.assertEqual([doc], rows)
59+
60
61 class PyDatabaseIndexTests(tests.DatabaseBaseTests):
62

Subscribers

People subscribed via source and target branches