Merge lp:~gary-lasker/software-center/catalog-published-date-lp803028-for-5.0 into lp:software-center/5.0

Proposed by Gary Lasker
Status: Merged
Merged at revision: 2492
Proposed branch: lp:~gary-lasker/software-center/catalog-published-date-lp803028-for-5.0
Merge into: lp:software-center/5.0
Diff against target: 193 lines (+57/-25)
5 files modified
debian/changelog (+9/-0)
softwarecenter/db/application.py (+7/-1)
softwarecenter/db/update.py (+20/-6)
softwarecenter/enums.py (+1/-0)
test/test_database.py (+20/-18)
To merge this branch: bzr merge lp:~gary-lasker/software-center/catalog-published-date-lp803028-for-5.0
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+96467@code.launchpad.net

Description of the change

This branch pulls in the published_date code from Precise (and fixes conflicts) for an SRU to fix bug 803028 for Oneiric (currently in the nominated state in the bug). The corresponding test case is included.

Thanks!

To post a comment you must log in.
Michael Vogt (mvo) wrote :

Thanks, looks good and works fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-05 18:28:46 +0000
3+++ debian/changelog 2012-03-07 21:59:19 +0000
4@@ -1,3 +1,12 @@
5+software-center (5.0.6) UNRELEASED; urgency=low
6+
7+ * lp:~gary-lasker/software-center/catalog-published-date-lp803028i-for-5.0:
8+ - use date_published value from the software-center-agent server
9+ so that for-purchase items appear correctly and in the proper order
10+ in What's New; include corresponding unit test (LP: #803028)
11+
12+ -- Gary Lasker <gary.lasker@canonical.com> Wed, 07 Mar 2012 16:44:27 -0500
13+
14 software-center (5.0.5) oneiric-proposed; urgency=low
15
16 [ Gary Lasker ]
17
18=== modified file 'softwarecenter/db/application.py'
19--- softwarecenter/db/application.py 2011-10-25 18:38:08 +0000
20+++ softwarecenter/db/application.py 2012-03-07 21:59:19 +0000
21@@ -328,7 +328,7 @@
22 from softwarecenter.db.history import get_pkg_history
23 self._history = get_pkg_history()
24 return self._history.get_installed_date(self.pkgname)
25-
26+
27 @property
28 def purchase_date(self):
29 if self._doc:
30@@ -348,6 +348,11 @@
31 return self._distro.get_license_text(self.component)
32
33 @property
34+ def date_published(self):
35+ if self._doc:
36+ return self._doc.get_value(XapianValues.DATE_PUBLISHED)
37+
38+ @property
39 def maintenance_status(self):
40 return self._distro.get_maintenance_status(
41 self._cache, self.display_name, self.pkgname, self.component,
42@@ -593,6 +598,7 @@
43 details.append(" installation_date: %s" % self.installation_date)
44 details.append(" purchase_date: %s" % self.purchase_date)
45 details.append(" license: %s" % self.license)
46+ details.append(" date_published: %s" % self.date_published)
47 details.append(" maintenance_status: %s" % self.maintenance_status)
48 details.append(" pkg_state: %s" % self.pkg_state)
49 details.append(" price: %s" % self.price)
50
51=== modified file 'softwarecenter/db/update.py'
52--- softwarecenter/db/update.py 2012-01-05 01:58:46 +0000
53+++ softwarecenter/db/update.py 2012-03-07 21:59:19 +0000
54@@ -22,8 +22,8 @@
55 import json
56 import string
57 import shutil
58+import xapian
59 import time
60-import xapian
61
62 from gi.repository import GObject
63
64@@ -143,6 +143,7 @@
65 'Deb-Line' : 'deb_line',
66 'Signing-Key-Id' : 'signing_key_id',
67 'License' : 'license',
68+ 'Date-Published' : 'date_published',
69 'Purchased-Date' : 'purchase_date',
70 'License-Key' : 'license_key',
71 'License-Key-Path' : 'license_key_path',
72@@ -617,11 +618,7 @@
73 if "catalogedtime" in axi_values:
74 if pkgname in cataloged_times:
75 doc.add_value(axi_values["catalogedtime"],
76- xapian.sortable_serialise(cataloged_times[pkgname]))
77- else:
78- # also catalog apps not found in axi (e.g. for-purchase apps)
79- doc.add_value(axi_values["catalogedtime"],
80- xapian.sortable_serialise(time.time()))
81+ xapian.sortable_serialise(cataloged_times[pkgname]))
82 # pocket (main, restricted, ...)
83 if parser.has_option_desktop("X-AppInstall-Section"):
84 archive_section = parser.get_desktop("X-AppInstall-Section")
85@@ -644,6 +641,23 @@
86 if parser.has_option_desktop("X-AppInstall-License"):
87 license = parser.get_desktop("X-AppInstall-License")
88 doc.add_value(XapianValues.LICENSE, license)
89+ # date published
90+ if parser.has_option_desktop("X-AppInstall-Date-Published"):
91+ date_published = parser.get_desktop("X-AppInstall-Date-Published")
92+ # strip the subseconds from the end of the published date string
93+ date_published = str(date_published).split(".")[0]
94+ doc.add_value(XapianValues.DATE_PUBLISHED,
95+ date_published)
96+ # we use the date published value for the cataloged time as well
97+ if "catalogedtime" in axi_values:
98+ LOG.debug(
99+ ("pkgname: %s, date_published cataloged time is: %s" %
100+ (pkgname, parser.get_desktop("date_published"))))
101+ date_published_sec = time.mktime(
102+ time.strptime(date_published,
103+ "%Y-%m-%d %H:%M:%S"))
104+ doc.add_value(axi_values["catalogedtime"],
105+ xapian.sortable_serialise(date_published_sec))
106 # purchased date
107 if parser.has_option_desktop("X-AppInstall-Purchased-Date"):
108 date = parser.get_desktop("X-AppInstall-Purchased-Date")
109
110=== modified file 'softwarecenter/enums.py'
111--- softwarecenter/enums.py 2011-10-16 16:58:26 +0000
112+++ softwarecenter/enums.py 2012-03-07 21:59:19 +0000
113@@ -124,6 +124,7 @@
114 LICENSE_KEY = 192
115 LICENSE_KEY_PATH = 193 # no longer used
116 LICENSE = 194
117+ DATE_PUBLISHED = 196
118
119 # fake channels
120 PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"
121
122=== modified file 'test/test_database.py'
123--- test/test_database.py 2012-01-09 17:14:21 +0000
124+++ test/test_database.py 2012-03-07 21:59:19 +0000
125@@ -15,7 +15,10 @@
126 from softwarecenter.db.enquire import AppEnquire
127 from softwarecenter.db.database import parse_axi_values_file
128 from softwarecenter.db.pkginfo import get_pkg_info
129-from softwarecenter.db.update import update_from_app_install_data, update_from_var_lib_apt_lists, update_from_appstream_xml
130+from softwarecenter.db.update import (update_from_app_install_data,
131+ update_from_var_lib_apt_lists,
132+ update_from_appstream_xml,
133+ update_from_software_center_agent)
134 from softwarecenter.enums import (
135 XapianValues,
136 PkgStates,
137@@ -94,7 +97,6 @@
138 self.assertEqual(db.get_doccount(), 1)
139
140 def test_build_from_software_center_agent(self):
141- from softwarecenter.db.update import update_from_software_center_agent
142 db = xapian.WritableDatabase("./data/test.db",
143 xapian.DB_CREATE_OR_OVERWRITE)
144 cache = apt.Cache()
145@@ -120,7 +122,6 @@
146 "-icon-" in doc.get_value(XapianValues.ICON))
147
148 def test_license_string_data_from_software_center_agent(self):
149- from softwarecenter.db.update import update_from_software_center_agent
150 from softwarecenter.testutils import get_test_pkg_info
151 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
152 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
153@@ -279,24 +280,25 @@
154 doc.get_value(value_time) >= last_time
155 last_time = doc.get_value(value_time)
156
157- def test_non_axi_apps_cataloged_time(self):
158+ def test_for_purchase_apps_date_published(self):
159+ from softwarecenter.testutils import get_test_pkg_info
160+ #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
161+ os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
162+ # staging does not have a valid cert
163+ os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
164+ cache = get_test_pkg_info()
165 db = xapian.WritableDatabase("./data/test.db",
166 xapian.DB_CREATE_OR_OVERWRITE)
167- res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
168+ res = update_from_software_center_agent(db, cache, ignore_cache=True)
169 self.assertTrue(res)
170- db = StoreDatabase("./data/test.db", self.cache)
171- db.open(use_axi=True)
172-
173- axi_value_time = db._axi_values["catalogedtime"]
174- sc_app = Application("Ubuntu Software Center Test", "software-center")
175- sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)
176- sc_cataloged_time = sc_doc.get_value(axi_value_time)
177- so_app = Application("Scintillant Orange", "scintillant-orange")
178- so_doc = db.get_xapian_document(so_app.appname, so_app.pkgname)
179- so_cataloged_time = so_doc.get_value(axi_value_time)
180- # the test package Scintillant Orange should be cataloged at a
181- # later time than axi package Ubuntu Software Center
182- self.assertTrue(so_cataloged_time > sc_cataloged_time)
183+
184+ for p in db.postlist(""):
185+ doc = db.get_document(p.docid)
186+ date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
187+ # make sure that a date_published value is provided
188+ self.assertNotEqual(date_published, "")
189+ self.assertNotEqual(date_published, None)
190+ del os.environ["SOFTWARE_CENTER_BUY_HOST"]
191
192 def test_parse_axi_values_file(self):
193 s = """

Subscribers

People subscribed via source and target branches