Merge lp:~mvo/software-center/fix-index-update-terms-bug into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3122
Proposed branch: lp:~mvo/software-center/fix-index-update-terms-bug
Merge into: lp:software-center
Diff against target: 39 lines (+17/-1)
2 files modified
softwarecenter/db/update.py (+1/-1)
tests/test_database.py (+16/-0)
To merge this branch: bzr merge lp:~mvo/software-center/fix-index-update-terms-bug
Reviewer Review Type Date Requested Status
James Westby (community) Approve
software-store-developers Pending
Review via email: mp+120533@code.launchpad.net

Description of the change

This fixes the default value of the self.FIELD_TO_TERMS.get() call to
return a empty list as we do not want to add the key split up in chars
as terms

To post a comment you must log in.
3114. By Michael Vogt

add regression test

3115. By Michael Vogt

tests/test_database.py: remove import of AppInfoParserBase, we don't need it

3116. By Michael Vogt

tests/test_database.py: remove string imprt that we don't really need

Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/update.py'
2--- softwarecenter/db/update.py 2012-08-01 04:37:06 +0000
3+++ softwarecenter/db/update.py 2012-08-22 09:06:20 +0000
4@@ -239,7 +239,7 @@
5 doc_key = self.FIELD_TO_XAPIAN[key]
6 doc.add_value(doc_key, value)
7 # add terms to the xapian database
8- get_terms = self.FIELD_TO_TERMS.get(key, lambda i: i)
9+ get_terms = self.FIELD_TO_TERMS.get(key, lambda i: [])
10 for t in get_terms(value):
11 doc.add_term(t)
12
13
14=== modified file 'tests/test_database.py'
15--- tests/test_database.py 2012-08-22 08:57:57 +0000
16+++ tests/test_database.py 2012-08-22 09:06:20 +0000
17@@ -92,6 +92,22 @@
18 i+=1
19 self.assertEqual(i, 1)
20
21+ def test_regression_index_terms(self):
22+ """ this tests for a regression that we had in the term indexer
23+ that would index hundrets of size 1 terms due to a bug
24+ in AppInfoParserBase._set_doc_from_key
25+ """
26+ db = xapian.WritableDatabase(TEST_DB,
27+ xapian.DB_CREATE_OR_OVERWRITE)
28+ update_from_app_install_data(db, self.cache,
29+ datadir=os.path.join(DATA_DIR, "desktop"))
30+ for it in db.postlist("APsoftware-center"):
31+ docid = it.docid
32+ break
33+ # this is the important part, ensure no signle char terms
34+ for t in db.termlist(docid):
35+ self.assertFalse(len(t.term) == 1)
36+
37 def test_update_from_appstream_xml(self):
38 db = xapian.WritableDatabase(TEST_DB,
39 xapian.DB_CREATE_OR_OVERWRITE)

Subscribers

People subscribed via source and target branches