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

Proposed by Gary Lasker
Status: Merged
Merged at revision: 2597
Proposed branch: lp:~gary-lasker/software-center/catalog-published-date-lp803028
Merge into: lp:software-center
Diff against target: 238 lines (+94/-16)
5 files modified
debian/changelog (+8/-1)
softwarecenter/db/application.py (+7/-1)
softwarecenter/db/update.py (+27/-3)
softwarecenter/enums.py (+1/-0)
test/test_database.py (+51/-11)
To merge this branch: bzr merge lp:~gary-lasker/software-center/catalog-published-date-lp803028
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+85401@code.launchpad.net

Description of the change

This branch implements the new 'date_published" field for for-purchase applications from the software-center-agent and incorporates it into catalog_times so that we display the for-purchase items in the What's New section correctly and in the correct order per their date of publication. This branch fixes bug 803028 and bug 86698.

The corresponding unit tests are added/updated. Note that currently the unit test points to the vpn test server because this functionality has not been deployed to the staging server yet. This is simply to prevent the unit tests failure before the staging server deployment is complete. I've marked this with a TODO to update it to point to the staging server once the support is there.

Finally, also note that I've left in the previous cataloged_time functionality as a fallback for for-purchase items so that these applications will not fall off the What's New list completely in the interim before the corresponding agent code is deployed on the production server. Once the agent is deployed, however, this fallback code will no longer be called and will have no effect. Nevertheless, I have marked it clearly with a TODO to remove it since it will serve no useful purpose after the production deployment is in place.

Should we also consider this fix as a candidate for an SRU to Oneiric?

Thanks!

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-12-12 12:45:41 +0000
+++ debian/changelog 2011-12-12 22:09:24 +0000
@@ -15,7 +15,14 @@
15 - Add a translator comment to the 'Top Rated %s' string, name the 15 - Add a translator comment to the 'Top Rated %s' string, name the
16 variable. LP: #86897116 variable. LP: #868971
1717
18 -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 09 Dec 2011 18:26:59 +010018 [ Gary Lasker ]
19 * lp:~gary-lasker/software-center/catalog-published-date-lp803028:
20 - add date_published value from the software-center-agent server
21 for use with cataloged time so that for-purchase items appear
22 correctly and in the proper order in What's New; include unit
23 tests for the new functionality (LP: #803028, LP: #886698
24
25 -- Gary Lasker <gary.lasker@canonical.com> Mon, 12 Dec 2011 16:45:32 -0500
1926
20software-center (5.1.3.1) precise; urgency=low27software-center (5.1.3.1) precise; urgency=low
2128
2229
=== modified file 'softwarecenter/db/application.py'
--- softwarecenter/db/application.py 2011-11-28 23:28:52 +0000
+++ softwarecenter/db/application.py 2011-12-12 22:09:24 +0000
@@ -339,7 +339,7 @@
339 from softwarecenter.db.history import get_pkg_history339 from softwarecenter.db.history import get_pkg_history
340 self._history = get_pkg_history()340 self._history = get_pkg_history()
341 return self._history.get_installed_date(self.pkgname)341 return self._history.get_installed_date(self.pkgname)
342 342
343 @property343 @property
344 def purchase_date(self):344 def purchase_date(self):
345 if self._doc:345 if self._doc:
@@ -359,6 +359,11 @@
359 return self._distro.get_license_text(self.component)359 return self._distro.get_license_text(self.component)
360360
361 @property361 @property
362 def date_published(self):
363 if self._doc:
364 return self._doc.get_value(XapianValues.DATE_PUBLISHED)
365
366 @property
362 def maintenance_status(self):367 def maintenance_status(self):
363 return self._distro.get_maintenance_status(368 return self._distro.get_maintenance_status(
364 self._cache, self.display_name, self.pkgname, self.component, 369 self._cache, self.display_name, self.pkgname, self.component,
@@ -671,6 +676,7 @@
671 details.append(" license: %s" % self.license)676 details.append(" license: %s" % self.license)
672 details.append(" license_key: %s" % self.license_key[0:3] + len(self.license_key)*"*")677 details.append(" license_key: %s" % self.license_key[0:3] + len(self.license_key)*"*")
673 details.append(" license_key_path: %s" % self.license_key_path)678 details.append(" license_key_path: %s" % self.license_key_path)
679 details.append(" date_published: %s" % self.date_published)
674 details.append(" maintenance_status: %s" % self.maintenance_status)680 details.append(" maintenance_status: %s" % self.maintenance_status)
675 details.append(" pkg_state: %s" % self.pkg_state)681 details.append(" pkg_state: %s" % self.pkg_state)
676 details.append(" price: %s" % self.price)682 details.append(" price: %s" % self.price)
677683
=== modified file 'softwarecenter/db/update.py'
--- softwarecenter/db/update.py 2011-12-12 09:15:52 +0000
+++ softwarecenter/db/update.py 2011-12-12 22:09:24 +0000
@@ -23,8 +23,8 @@
23import json23import json
24import string24import string
25import shutil25import shutil
26import xapian
26import time27import time
27import xapian
2828
29from gi.repository import GObject29from gi.repository import GObject
3030
@@ -144,6 +144,7 @@
144 'Deb-Line' : 'deb_line',144 'Deb-Line' : 'deb_line',
145 'Signing-Key-Id' : 'signing_key_id',145 'Signing-Key-Id' : 'signing_key_id',
146 'License' : 'license',146 'License' : 'license',
147 'Date-Published' : 'date_published',
147 'Purchased-Date' : 'purchase_date',148 'Purchased-Date' : 'purchase_date',
148 'License-Key' : 'license_key',149 'License-Key' : 'license_key',
149 'License-Key-Path' : 'license_key_path',150 'License-Key-Path' : 'license_key_path',
@@ -544,7 +545,7 @@
544 try:545 try:
545 # magic channel546 # magic channel
546 entry.channel = AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME547 entry.channel = AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME
547 # icon is transmited inline548 # icon is transmitted inline
548 if hasattr(entry, "icon_data") and entry.icon_data:549 if hasattr(entry, "icon_data") and entry.icon_data:
549 icondata = base64.b64decode(entry.icon_data)550 icondata = base64.b64decode(entry.icon_data)
550 elif hasattr(entry, "icon_64_data") and entry.icon_64_data:551 elif hasattr(entry, "icon_64_data") and entry.icon_64_data:
@@ -637,9 +638,15 @@
637 doc.add_value(axi_values["catalogedtime"], 638 doc.add_value(axi_values["catalogedtime"],
638 xapian.sortable_serialise(cataloged_times[pkgname]))639 xapian.sortable_serialise(cataloged_times[pkgname]))
639 else:640 else:
640 # also catalog apps not found in axi (e.g. for-purchase apps)641 #####################################################
642 # TODO: This is just a fallback so that we keep our current
643 # behavior of having new items for-purchase appear in
644 # what's new...THIS SHOULD BE REMOVED after support
645 # for date_purchased in the agent has been deployed
646 # to the production server
641 doc.add_value(axi_values["catalogedtime"], 647 doc.add_value(axi_values["catalogedtime"],
642 xapian.sortable_serialise(time.time()))648 xapian.sortable_serialise(time.time()))
649 #####################################################
643 # pocket (main, restricted, ...)650 # pocket (main, restricted, ...)
644 if parser.has_option_desktop("X-AppInstall-Section"):651 if parser.has_option_desktop("X-AppInstall-Section"):
645 archive_section = parser.get_desktop("X-AppInstall-Section")652 archive_section = parser.get_desktop("X-AppInstall-Section")
@@ -662,6 +669,23 @@
662 if parser.has_option_desktop("X-AppInstall-License"):669 if parser.has_option_desktop("X-AppInstall-License"):
663 license = parser.get_desktop("X-AppInstall-License")670 license = parser.get_desktop("X-AppInstall-License")
664 doc.add_value(XapianValues.LICENSE, license)671 doc.add_value(XapianValues.LICENSE, license)
672 # date published
673 if parser.has_option_desktop("X-AppInstall-Date-Published"):
674 date_published = parser.get_desktop("X-AppInstall-Date-Published")
675 # strip the subseconds from the end of the published date string
676 date_published = str(date_published).split(".")[0]
677 doc.add_value(XapianValues.DATE_PUBLISHED,
678 date_published)
679 # we use the date published value for the cataloged time as well
680 if "catalogedtime" in axi_values:
681 LOG.debug(
682 ("pkgname: %s, date_published cataloged time is: %s" %
683 (pkgname, parser.get_desktop("date_published"))))
684 date_published_sec = time.mktime(
685 time.strptime(date_published,
686 "%Y-%m-%d %H:%M:%S"))
687 doc.add_value(axi_values["catalogedtime"],
688 xapian.sortable_serialise(date_published_sec))
665 # purchased date689 # purchased date
666 if parser.has_option_desktop("X-AppInstall-Purchased-Date"):690 if parser.has_option_desktop("X-AppInstall-Purchased-Date"):
667 date = parser.get_desktop("X-AppInstall-Purchased-Date")691 date = parser.get_desktop("X-AppInstall-Purchased-Date")
668692
=== modified file 'softwarecenter/enums.py'
--- softwarecenter/enums.py 2011-11-11 03:05:45 +0000
+++ softwarecenter/enums.py 2011-12-12 22:09:24 +0000
@@ -129,6 +129,7 @@
129 LICENSE_KEY_PATH = 193 # no longer used129 LICENSE_KEY_PATH = 193 # no longer used
130 LICENSE = 194130 LICENSE = 194
131 VIDEO_URL = 195131 VIDEO_URL = 195
132 DATE_PUBLISHED = 196
132133
133# fake channels134# fake channels
134PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"135PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"
135136
=== modified file 'test/test_database.py'
--- test/test_database.py 2011-10-07 14:48:05 +0000
+++ test/test_database.py 2011-12-12 22:09:24 +0000
@@ -15,7 +15,10 @@
15from softwarecenter.db.enquire import AppEnquire15from softwarecenter.db.enquire import AppEnquire
16from softwarecenter.db.database import parse_axi_values_file16from softwarecenter.db.database import parse_axi_values_file
17from softwarecenter.db.pkginfo import get_pkg_info17from softwarecenter.db.pkginfo import get_pkg_info
18from softwarecenter.db.update import update_from_app_install_data, update_from_var_lib_apt_lists, update_from_appstream_xml18from softwarecenter.db.update import (update_from_app_install_data,
19 update_from_var_lib_apt_lists,
20 update_from_appstream_xml,
21 update_from_software_center_agent)
19from softwarecenter.enums import (22from softwarecenter.enums import (
20 XapianValues,23 XapianValues,
21 PkgStates,24 PkgStates,
@@ -94,7 +97,6 @@
94 self.assertEqual(db.get_doccount(), 1)97 self.assertEqual(db.get_doccount(), 1)
9598
96 def test_build_from_software_center_agent(self):99 def test_build_from_software_center_agent(self):
97 from softwarecenter.db.update import update_from_software_center_agent
98 db = xapian.WritableDatabase("./data/test.db", 100 db = xapian.WritableDatabase("./data/test.db",
99 xapian.DB_CREATE_OR_OVERWRITE)101 xapian.DB_CREATE_OR_OVERWRITE)
100 cache = apt.Cache()102 cache = apt.Cache()
@@ -120,7 +122,6 @@
120 doc.get_value(XapianValues.ICON).startswith("sc-agent"))122 doc.get_value(XapianValues.ICON).startswith("sc-agent"))
121123
122 def test_license_string_data_from_software_center_agent(self):124 def test_license_string_data_from_software_center_agent(self):
123 from softwarecenter.db.update import update_from_software_center_agent
124 from softwarecenter.testutils import get_test_pkg_info125 from softwarecenter.testutils import get_test_pkg_info
125 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"126 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
126 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"127 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
@@ -279,9 +280,45 @@
279 doc.get_value(value_time) >= last_time280 doc.get_value(value_time) >= last_time
280 last_time = doc.get_value(value_time)281 last_time = doc.get_value(value_time)
281 282
282 def test_non_axi_apps_cataloged_time(self):283 def test_for_purchase_apps_date_published(self):
283 db = xapian.WritableDatabase("./data/test.db", 284 from softwarecenter.testutils import get_test_pkg_info
284 xapian.DB_CREATE_OR_OVERWRITE)285 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
286 ####################################################################
287 # TODO: Point the following back to http://sc.staging.ubuntu.com/ once
288 # the support for published date is deployed there
289 ####################################################################
290 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sca.razorgirl.info"
291 # staging does not have a valid cert
292 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
293 cache = get_test_pkg_info()
294 db = xapian.WritableDatabase("./data/test.db",
295 xapian.DB_CREATE_OR_OVERWRITE)
296 res = update_from_software_center_agent(db, cache, ignore_cache=True)
297 self.assertTrue(res)
298
299 for p in db.postlist(""):
300 doc = db.get_document(p.docid)
301 date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
302 # make sure that a date_published value is provided
303 self.assertNotEqual(date_published, "")
304 self.assertNotEqual(date_published, None)
305 del os.environ["SOFTWARE_CENTER_BUY_HOST"]
306
307 def test_for_purchase_apps_cataloged_time(self):
308 from softwarecenter.testutils import get_test_pkg_info
309 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
310 ####################################################################
311 # TODO: Point the following back to http://sc.staging.ubuntu.com/ once
312 # the support for published date is deployed there
313 ####################################################################
314 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sca.razorgirl.info"
315 # staging does not have a valid cert
316 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
317 cache = get_test_pkg_info()
318 db = xapian.WritableDatabase("./data/test.db",
319 xapian.DB_CREATE_OR_OVERWRITE)
320 res = update_from_software_center_agent(db, cache, ignore_cache=True)
321 self.assertTrue(res)
285 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")322 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
286 self.assertTrue(res)323 self.assertTrue(res)
287 db = StoreDatabase("./data/test.db", self.cache)324 db = StoreDatabase("./data/test.db", self.cache)
@@ -291,12 +328,15 @@
291 sc_app = Application("Ubuntu Software Center Test", "software-center")328 sc_app = Application("Ubuntu Software Center Test", "software-center")
292 sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)329 sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)
293 sc_cataloged_time = sc_doc.get_value(axi_value_time)330 sc_cataloged_time = sc_doc.get_value(axi_value_time)
294 so_app = Application("Scintillant Orange", "scintillant-orange")331 for_purch_app = Application("For Purchase Test App", "hellox")
295 so_doc = db.get_xapian_document(so_app.appname, so_app.pkgname)332 for_purch_doc = db.get_xapian_document(for_purch_app.appname,
296 so_cataloged_time = so_doc.get_value(axi_value_time)333 for_purch_app.pkgname)
297 # the test package Scintillant Orange should be cataloged at a334 for_purch_cataloged_time = for_purch_doc.get_value(axi_value_time)
335 # the for-purchase test package should be cataloged at a
298 # later time than axi package Ubuntu Software Center336 # later time than axi package Ubuntu Software Center
299 self.assertTrue(so_cataloged_time > sc_cataloged_time)337 self.assertTrue(for_purch_cataloged_time > sc_cataloged_time)
338
339 del os.environ["SOFTWARE_CENTER_BUY_HOST"]
300340
301 def test_parse_axi_values_file(self):341 def test_parse_axi_values_file(self):
302 s = """342 s = """

Subscribers

People subscribed via source and target branches