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.
Revision history for this message
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
=== modified file 'debian/changelog'
--- debian/changelog 2012-03-05 18:28:46 +0000
+++ debian/changelog 2012-03-07 21:59:19 +0000
@@ -1,3 +1,12 @@
1software-center (5.0.6) UNRELEASED; urgency=low
2
3 * lp:~gary-lasker/software-center/catalog-published-date-lp803028i-for-5.0:
4 - use date_published value from the software-center-agent server
5 so that for-purchase items appear correctly and in the proper order
6 in What's New; include corresponding unit test (LP: #803028)
7
8 -- Gary Lasker <gary.lasker@canonical.com> Wed, 07 Mar 2012 16:44:27 -0500
9
1software-center (5.0.5) oneiric-proposed; urgency=low10software-center (5.0.5) oneiric-proposed; urgency=low
211
3 [ Gary Lasker ]12 [ Gary Lasker ]
413
=== modified file 'softwarecenter/db/application.py'
--- softwarecenter/db/application.py 2011-10-25 18:38:08 +0000
+++ softwarecenter/db/application.py 2012-03-07 21:59:19 +0000
@@ -328,7 +328,7 @@
328 from softwarecenter.db.history import get_pkg_history328 from softwarecenter.db.history import get_pkg_history
329 self._history = get_pkg_history()329 self._history = get_pkg_history()
330 return self._history.get_installed_date(self.pkgname)330 return self._history.get_installed_date(self.pkgname)
331 331
332 @property332 @property
333 def purchase_date(self):333 def purchase_date(self):
334 if self._doc:334 if self._doc:
@@ -348,6 +348,11 @@
348 return self._distro.get_license_text(self.component)348 return self._distro.get_license_text(self.component)
349349
350 @property350 @property
351 def date_published(self):
352 if self._doc:
353 return self._doc.get_value(XapianValues.DATE_PUBLISHED)
354
355 @property
351 def maintenance_status(self):356 def maintenance_status(self):
352 return self._distro.get_maintenance_status(357 return self._distro.get_maintenance_status(
353 self._cache, self.display_name, self.pkgname, self.component, 358 self._cache, self.display_name, self.pkgname, self.component,
@@ -593,6 +598,7 @@
593 details.append(" installation_date: %s" % self.installation_date)598 details.append(" installation_date: %s" % self.installation_date)
594 details.append(" purchase_date: %s" % self.purchase_date)599 details.append(" purchase_date: %s" % self.purchase_date)
595 details.append(" license: %s" % self.license)600 details.append(" license: %s" % self.license)
601 details.append(" date_published: %s" % self.date_published)
596 details.append(" maintenance_status: %s" % self.maintenance_status)602 details.append(" maintenance_status: %s" % self.maintenance_status)
597 details.append(" pkg_state: %s" % self.pkg_state)603 details.append(" pkg_state: %s" % self.pkg_state)
598 details.append(" price: %s" % self.price)604 details.append(" price: %s" % self.price)
599605
=== modified file 'softwarecenter/db/update.py'
--- softwarecenter/db/update.py 2012-01-05 01:58:46 +0000
+++ softwarecenter/db/update.py 2012-03-07 21:59:19 +0000
@@ -22,8 +22,8 @@
22import json22import json
23import string23import string
24import shutil24import shutil
25import xapian
25import time26import time
26import xapian
2727
28from gi.repository import GObject28from gi.repository import GObject
2929
@@ -143,6 +143,7 @@
143 'Deb-Line' : 'deb_line',143 'Deb-Line' : 'deb_line',
144 'Signing-Key-Id' : 'signing_key_id',144 'Signing-Key-Id' : 'signing_key_id',
145 'License' : 'license',145 'License' : 'license',
146 'Date-Published' : 'date_published',
146 'Purchased-Date' : 'purchase_date',147 'Purchased-Date' : 'purchase_date',
147 'License-Key' : 'license_key',148 'License-Key' : 'license_key',
148 'License-Key-Path' : 'license_key_path',149 'License-Key-Path' : 'license_key_path',
@@ -617,11 +618,7 @@
617 if "catalogedtime" in axi_values:618 if "catalogedtime" in axi_values:
618 if pkgname in cataloged_times:619 if pkgname in cataloged_times:
619 doc.add_value(axi_values["catalogedtime"], 620 doc.add_value(axi_values["catalogedtime"],
620 xapian.sortable_serialise(cataloged_times[pkgname]))621 xapian.sortable_serialise(cataloged_times[pkgname]))
621 else:
622 # also catalog apps not found in axi (e.g. for-purchase apps)
623 doc.add_value(axi_values["catalogedtime"],
624 xapian.sortable_serialise(time.time()))
625 # pocket (main, restricted, ...)622 # pocket (main, restricted, ...)
626 if parser.has_option_desktop("X-AppInstall-Section"):623 if parser.has_option_desktop("X-AppInstall-Section"):
627 archive_section = parser.get_desktop("X-AppInstall-Section")624 archive_section = parser.get_desktop("X-AppInstall-Section")
@@ -644,6 +641,23 @@
644 if parser.has_option_desktop("X-AppInstall-License"):641 if parser.has_option_desktop("X-AppInstall-License"):
645 license = parser.get_desktop("X-AppInstall-License")642 license = parser.get_desktop("X-AppInstall-License")
646 doc.add_value(XapianValues.LICENSE, license)643 doc.add_value(XapianValues.LICENSE, license)
644 # date published
645 if parser.has_option_desktop("X-AppInstall-Date-Published"):
646 date_published = parser.get_desktop("X-AppInstall-Date-Published")
647 # strip the subseconds from the end of the published date string
648 date_published = str(date_published).split(".")[0]
649 doc.add_value(XapianValues.DATE_PUBLISHED,
650 date_published)
651 # we use the date published value for the cataloged time as well
652 if "catalogedtime" in axi_values:
653 LOG.debug(
654 ("pkgname: %s, date_published cataloged time is: %s" %
655 (pkgname, parser.get_desktop("date_published"))))
656 date_published_sec = time.mktime(
657 time.strptime(date_published,
658 "%Y-%m-%d %H:%M:%S"))
659 doc.add_value(axi_values["catalogedtime"],
660 xapian.sortable_serialise(date_published_sec))
647 # purchased date661 # purchased date
648 if parser.has_option_desktop("X-AppInstall-Purchased-Date"):662 if parser.has_option_desktop("X-AppInstall-Purchased-Date"):
649 date = parser.get_desktop("X-AppInstall-Purchased-Date")663 date = parser.get_desktop("X-AppInstall-Purchased-Date")
650664
=== modified file 'softwarecenter/enums.py'
--- softwarecenter/enums.py 2011-10-16 16:58:26 +0000
+++ softwarecenter/enums.py 2012-03-07 21:59:19 +0000
@@ -124,6 +124,7 @@
124 LICENSE_KEY = 192124 LICENSE_KEY = 192
125 LICENSE_KEY_PATH = 193 # no longer used125 LICENSE_KEY_PATH = 193 # no longer used
126 LICENSE = 194126 LICENSE = 194
127 DATE_PUBLISHED = 196
127128
128# fake channels129# fake channels
129PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"130PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"
130131
=== modified file 'test/test_database.py'
--- test/test_database.py 2012-01-09 17:14:21 +0000
+++ test/test_database.py 2012-03-07 21:59:19 +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 "-icon-" in doc.get_value(XapianValues.ICON))122 "-icon-" in doc.get_value(XapianValues.ICON))
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,24 +280,25 @@
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):
284 from softwarecenter.testutils import get_test_pkg_info
285 #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
286 os.environ["SOFTWARE_CENTER_BUY_HOST"] = "http://sc.staging.ubuntu.com/"
287 # staging does not have a valid cert
288 os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
289 cache = get_test_pkg_info()
283 db = xapian.WritableDatabase("./data/test.db", 290 db = xapian.WritableDatabase("./data/test.db",
284 xapian.DB_CREATE_OR_OVERWRITE)291 xapian.DB_CREATE_OR_OVERWRITE)
285 res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")292 res = update_from_software_center_agent(db, cache, ignore_cache=True)
286 self.assertTrue(res)293 self.assertTrue(res)
287 db = StoreDatabase("./data/test.db", self.cache)294
288 db.open(use_axi=True)295 for p in db.postlist(""):
289296 doc = db.get_document(p.docid)
290 axi_value_time = db._axi_values["catalogedtime"]297 date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
291 sc_app = Application("Ubuntu Software Center Test", "software-center")298 # make sure that a date_published value is provided
292 sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)299 self.assertNotEqual(date_published, "")
293 sc_cataloged_time = sc_doc.get_value(axi_value_time)300 self.assertNotEqual(date_published, None)
294 so_app = Application("Scintillant Orange", "scintillant-orange")301 del os.environ["SOFTWARE_CENTER_BUY_HOST"]
295 so_doc = db.get_xapian_document(so_app.appname, so_app.pkgname)
296 so_cataloged_time = so_doc.get_value(axi_value_time)
297 # the test package Scintillant Orange should be cataloged at a
298 # later time than axi package Ubuntu Software Center
299 self.assertTrue(so_cataloged_time > sc_cataloged_time)
300302
301 def test_parse_axi_values_file(self):303 def test_parse_axi_values_file(self):
302 s = """304 s = """

Subscribers

People subscribed via source and target branches