~nik90/ubuntu/precise/software-center/add_keywords

« back to all changes in this revision

Viewing changes to test/test_database.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Gabor Kelemen, Michael Vogt, Kiwinote, Gary Lasker, Juhana Jauhiainen
  • Date: 2012-02-15 19:19:32 UTC
  • Revision ID: package-import@ubuntu.com-20120215191932-ep1hp9tcay31djge
Tags: 5.1.9
[ Gabor Kelemen ]  
* lp:~kelemeng/software-center/bug926743:
  - Mark strings for translation, add translator comment where needed
    (LP: #926743)

[ Michael Vogt ]
* lp:~mvo/software-center/latest-recommender:
  - import latest recommender client
* lp:~mvo/software-center/dynamic-region-menu:
  - allow dynamic template in the software-center.menu file, currently
    supported is ${CURRENT_REGION}. This allows to build a dynamic
    "Your region" menu once we actually tag packages with the region
    information
* lp:~mvo/software-center/sca-video:
  - add the ability to display embedded videos in the application
    details view
* lp:~mvo/software-center/multiple-screenshots:
  - add support for the display of multiple screenshots in the
    application details view, as provided by the software-center-agent
* lp:~mvo/software-center/submit-review-hang-fix:
  - fix hang when submitting a review on precise
* lp:~mvo/software-center/screenshots-sorting:
  - ensure the multiple screenshots are sorted properly when
    they come from the json API
* lp:~mvo/software-center/sca-video-updates:
  - update the client to follow the server side changes for
    videos from software-center-agent
* lp:~mvo/software-center/video-ui-reshuffle:
  - shuffle the video location around a bit in the view to
    ensure the user finds it more easily
* increase dependency on python-apt for the required
  apt_pkg.DepCache.policy_priority() support
* lp:~mvo/software-center/sca-debtags:
  - fix the debtags parsing from the software-center-agent
* lp:~mvo/software-center/multiple-versions:
  - add support for multiple versions into software-center
* lp:~mvo/software-center/fix-recommenations-details-clicks:
  - fix clickthru of details view recommendations after refactor
* lp:~mvo/software-center/rfc3166-use-common-name:
  - ensure that "common_name" in rfc3166 is used when available
    to avoid political issues around the name of the region

[ Kiwinote ]
* data/ui/gtk3/css/*.css:
  - use 'px' suffixes as required by latest gtk
* softwarecenter/ui/gtk3/views/appdetailsview.py:
  - replace ... and ' with their unicode eequivalents (LP: #844799)
* softwarecenter/db/application.py:
  - don't crash if the version nr associated with a screenshot is None

[ Gary Lasker ]
* lp:~gary-lasker/software-center/recommender-service-url:
  - update to the correct production url for the recommender
    service 
* lp:~gary-lasker/software-center/import-latest-sreclient:
  - import latest recommender client 
* lp:~gary-lasker/software-center/recommendation:
  - implement the recommendations opt-in UI and flow, upload
    of the user profile data after opt-in, and display of
    per-application recommendations in the details view
* lp:~gary-lasker/software-center/temp-disable-lobby-recommendations-view:
  - temporarily hide the lobby recommendations opt-in and display
    view pending rollout of the corresponding support on the
    production server

[ Juhana Jauhiainen ]
* softwarecenter/backend/launchpad.py:
  - replaced EDGE_SERVICE_ROOT with LPNET_SERVICE_ROOT. (LP: #737697)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        self.cache = get_pkg_info()
50
50
        self.cache.open()
51
51
 
 
52
    def test_multiple_versions_sorting(self):
 
53
        db = get_test_db()
 
54
        app = Application("", "software-center")
 
55
        details = AppDetails(db, application=app)
 
56
        details._pkg = Mock()
 
57
        details._pkg.installed = Mock()
 
58
        details._pkg.installed.version  = "2.0"
 
59
        self.assertEqual(details.version, "2.0")
 
60
        v0 = { "version" : None, }
 
61
        v1 = { "version" : "1.0", }
 
62
        v2 = { "version" : "2.0", }
 
63
        v3 = { "version" : "3.0", }
 
64
        screenshots_list = [ v0, v1, v2, v3 ]
 
65
        res = details._sort_screenshots_by_best_version(screenshots_list)
 
66
        self.assertEqual(res, [ v2, v1, v0 ])
 
67
 
 
68
 
52
69
    def test_update_from_desktop_file(self):
53
70
        # ensure we index with german locales to test i18n
54
71
        os.environ["LANGUAGE"] = "de"
196
213
        self.assertNotEqual(appdetails.pkg, None)
197
214
        # from the fake test/data/appdetails/var/lib/dpkg/status
198
215
        self.assertEqual(appdetails.pkg.is_installed, True)
199
 
        self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
 
216
        self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED,
 
217
                                                 PkgStates.UPGRADABLE))
200
218
        # FIXME: test description for unavailable pkg
201
219
        self.assertTrue(
202
220
            appdetails.description.startswith("Ubuntu Software Center lets you"))
224
242
        details = app.get_details(db)
225
243
        distro = get_distro().get_codename()
226
244
        self.assertEqual(app.request, 'channel=' + distro + '-partner')
227
 
 
 
245
    
228
246
    def ensure_installation_date_and_lazy_history_loading(self, appdetails):
229
247
        # we run two tests, the first is to ensure that we get a
230
248
        # result from installation_data immediately (at this point the
251
269
        # FIXME: this will only work if software-center is installed
252
270
        app = Application("Ubuntu Software Center Test", "software-center")
253
271
        appdetails = app.get_details(db)
254
 
        self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
 
272
        self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED,
 
273
                                                  PkgStates.UPGRADABLE))
255
274
        # test PkgStates.UNINSTALLED
256
275
        # test PkgStates.UPGRADABLE
257
276
        # test PkgStates.REINSTALLABLE
438
457
                           nonblocking_load=False)
439
458
        self.assertTrue(len(enquirer.get_docids()) > 0)
440
459
        # FIXME: test more of the interface
 
460
        
 
461
    def test_utils_get_installed_package_list(self):
 
462
        from softwarecenter.db.utils import get_installed_package_list
 
463
        installed_pkgs = get_installed_package_list()
 
464
        self.assertTrue(len(installed_pkgs) > 0)
441
465
 
442
466
 
443
467
def make_purchased_app_details(db=None, supported_series=None):
586
610
            PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED,
587
611
            state)
588
612
 
 
613
class MultipleVersionsSupportTestCase(unittest.TestCase):
 
614
 
 
615
    def _make_version(self, not_automatic):
 
616
        from softwarecenter.db.pkginfo import _Version
 
617
        ver = Mock(_Version)
 
618
        ver.description ="not_automatic: %s" % not_automatic
 
619
        ver.summary ="summary not_automatic: %s" % not_automatic
 
620
        ver.version = "version not_automatic: %s" % not_automatic
 
621
        mock_origin = Mock()
 
622
        if not_automatic:
 
623
            mock_origin.archive = "precise-backports"
 
624
        else:
 
625
            mock_origin.archive = "precise"
 
626
        ver.origins = [ mock_origin ]
 
627
        ver.not_automatic = not_automatic
 
628
        return ver
 
629
 
 
630
    def test_not_automatic_channel_support(self):
 
631
        db = get_test_db()
 
632
        app = Application("", "software-center")
 
633
        details = app.get_details(db)
 
634
        versions = [ 
 
635
            self._make_version(not_automatic=True),
 
636
            self._make_version(not_automatic=False) ]
 
637
        details._pkg.versions = versions
 
638
        details._pkg.candidate = versions[1]
 
639
        self.assertEqual(
 
640
            details.get_not_automatic_archive_versions(), 
 
641
            [  (versions[1].version, "precise"),
 
642
               (versions[0].version, "precise-backports") ])
 
643
 
 
644
    def test_multiple_version_pkg_states(self):
 
645
        db = get_test_db()
 
646
        app = Application("", "software-center")
 
647
        details = app.get_details(db)
 
648
        normal_version = self._make_version(not_automatic=False)
 
649
        not_automatic_version = self._make_version(not_automatic=True)
 
650
        details._pkg.versions = [normal_version, not_automatic_version]
 
651
        details._pkg.installed = normal_version
 
652
        details._pkg.is_installed = True
 
653
        details._pkg.is_upgradable = True
 
654
        self.assertEqual(details.pkg_state, PkgStates.UPGRADABLE)
 
655
        app.archive_suite = not_automatic_version
 
656
        self.assertEqual(details.pkg_state, PkgStates.FORCE_VERSION)
 
657
 
 
658
    def test_not_automatic_version(self):
 
659
        db = get_test_db()
 
660
        app = Application("", "software-center")
 
661
        details = app.get_details(db)
 
662
        normal_version = self._make_version(not_automatic=False)
 
663
        not_automatic_version = self._make_version(not_automatic=True)
 
664
        details._pkg.versions = [normal_version, not_automatic_version]
 
665
        # force not-automatic with invalid data
 
666
        self.assertRaises(
 
667
            ValueError, details.force_not_automatic_archive_suite, "random-string")
 
668
        # force not-automatic with valid data
 
669
        self.assertTrue(details.force_not_automatic_archive_suite(
 
670
                not_automatic_version.origins[0].archive))
 
671
        # ensure we get the description of the not-automatic version
 
672
        self.assertEqual(details.description,
 
673
                         not_automatic_version.description)
 
674
        self.assertEqual(details.summary,
 
675
                         not_automatic_version.summary)
 
676
        self.assertEqual(details.version,
 
677
                         not_automatic_version.version)
 
678
        self.assertEqual(app.archive_suite,
 
679
                         not_automatic_version.origins[0].archive)
 
680
        # clearing works
 
681
        details.force_not_automatic_archive_suite("")
 
682
        self.assertEqual(app.archive_suite, "")
589
683
 
590
684
 
591
685
if __name__ == "__main__":
592
 
    import logging
593
 
    logging.basicConfig(level=logging.DEBUG)
 
686
    #import logging
 
687
    #logging.basicConfig(level=logging.DEBUG)
594
688
    unittest.main()