Beispiel #1
0
 def test_package_states(self):
     db = xapian.WritableDatabase("./data/test.db", 
                                  xapian.DB_CREATE_OR_OVERWRITE)
     res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
     self.assertTrue(res)
     db = StoreDatabase("./data/test.db", self.cache)
     db.open(use_axi=False)
     # test PkgStates.INSTALLED
     # FIXME: this will only work if software-center is installed
     app = Application("Ubuntu Software Center Test", "software-center")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
     # test PkgStates.UNINSTALLED
     # test PkgStates.UPGRADABLE
     # test PkgStates.REINSTALLABLE
     # test PkgStates.INSTALLING
     # test PkgStates.REMOVING
     # test PkgStates.UPGRADING
     # test PkgStates.NEEDS_SOURCE
     app = Application("Zynjacku Test", "zynjacku-fake")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_SOURCE)
     # test PkgStates.NEEDS_PURCHASE
     app = Application("The expensive gem", "expensive-gem")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_PURCHASE)
     self.assertEqual(appdetails.icon_url, "http://www.google.com/favicon.ico")
     self.assertEqual(appdetails.icon, "favicon")
     # test PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED
     # test PkgStates.UNKNOWN
     app = Application("Scintillant Orange", "scintillant-orange")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NOT_FOUND)
Beispiel #2
0
 def test_reviews_page(self):
     # show s-c and click on more review
     app = Application("", "software-center")
     self.view.show_app(app)
     self.assertEqual(self.view._reviews_server_page, 1)
     self.view._on_more_reviews_clicked(None)
     self.assertEqual(self.view._reviews_server_page, 2)
     # show different app, ensure page is reset
     app = Application("", "apt")
     self.view.show_app(app)
     self.assertEqual(self.view._reviews_server_page, 1)
 def test_reviews_page(self):
     win = get_test_window_appdetails()
     view = win.get_data("view")
     # show s-c and click on more review
     app = Application("", "software-center")
     view.show_app(app)
     self.assertEqual(view._reviews_server_page, 1)
     view._on_more_reviews_clicked(None)
     self.assertEqual(view._reviews_server_page, 2)
     # show different app, ensure page is reset
     app = Application("", "apt")
     view.show_app(app)
     self.assertEqual(view._reviews_server_page, 1)
 def __call__(self, doc):
     app = Application(self.db.get_appname(doc), self.db.get_pkgname(doc))
     stats = self.review_loader.get_review_stats(app)
     import xapian
     if stats:
         return xapian.sortable_serialise(stats.dampened_rating)
     return xapian.sortable_serialise(0)
 def get_most_popular_applications_for_mimetype(self,
                                                mimetype,
                                                only_uninstalled=True,
                                                num=3):
     """ return a list of the most popular applications for the given
         mimetype
     """
     # sort by popularity by default
     enquire = xapian.Enquire(self.xapiandb)
     enquire.set_sort_by_value_then_relevance(XapianValues.POPCON)
     # query mimetype
     query = xapian.Query("AM%s" % mimetype)
     enquire.set_query(query)
     # mset just needs to be "big enough""
     matches = enquire.get_mset(0, 100)
     apps = []
     for match in matches:
         doc = match.document
         app = Application(self.get_appname(doc),
                           self.get_pkgname(doc),
                           popcon=self.get_popcon(doc))
         if only_uninstalled:
             if app.get_details(self).pkg_state == PkgStates.UNINSTALLED:
                 apps.append(app)
         else:
             apps.append(app)
         if len(apps) == num:
             break
     return apps
 def test_add_license_key_backend(self):
     self._finished = False
     # add repo
     deb_line = "deb https://mvo:[email protected]/canonical-isd-hackers/internal-qa/ubuntu oneiric main"
     signing_key_id = "F5410BE0"
     app = Application("Test app1", self.PKGNAME)
     # install only when runnig as root, as we require polkit promtps
     # otherwise
     # FIXME: provide InstallBackendSimulate()
     if os.getuid() == 0:
         backend = get_install_backend()
         backend.ui = Mock()
         backend.connect("transaction-finished",
                         self._on_transaction_finished)
         # simulate repos becomes available for the public 20 s later
         GObject.timeout_add_seconds(20, self._add_pw_to_commercial_repo)
         # run it
         backend.add_repo_add_key_and_install_app(deb_line, signing_key_id,
                                                  app, "icon",
                                                  self.LICENSE_KEY)
         # wait until the pkg is installed
         while not self._finished:
             while Gtk.events_pending():
                 Gtk.main_iteration()
             time.sleep(0.1)
     if os.getuid() == 0:
         self.assertTrue(os.path.exists(self.LICENSE_KEY_PATH))
         self.assertEqual(
             open(self.LICENSE_KEY_PATH).read(), self.LICENSE_KEY)
    def test_videoplayer(self):
        # show app with no video
        app = Application("", "2vcard")
        self.view.show_app(app)
        do_events()
        self.assertFalse(self.view.videoplayer.get_property("visible"))

        # create app with video and ensure its visible
        app = Application("", "synaptic")
        mock = get_mock_app_from_real_app(app)
        details = mock.get_details(None)
        # this is a example html - any html5 video will do
        details.video_url = "http://people.canonical.com/~mvo/totem.html"
        self.view.show_app(mock)
        do_events()
        self.assertTrue(self.view.videoplayer.get_property("visible"))
Beispiel #8
0
    def test_appmanager(self):
        app_manager = get_appmanager()
        self.assertNotEqual(app_manager, None)
        # test interface
        app_manager.reload()
        app = Application("", "2vcard")
        # call and ensure the stuff is passed to the backend
        app_manager.install(app, [], [])
        self.assertTrue(self.backend.install.called)

        app_manager.remove(app, [], [])
        self.assertTrue(self.backend.remove.called)

        app_manager.upgrade(app, [], [])
        self.assertTrue(self.backend.upgrade.called)

        app_manager.apply_changes(app, [], [])
        self.assertTrue(self.backend.apply_changes.called)

        app_manager.enable_software_source(app)
        self.assertTrue(self.backend.enable_component.called)

        app_manager.reinstall_purchased(app)
        self.assertTrue(self.backend.add_repo_add_key_and_install_app.called)

        # buy is special as it needs help from the purchase view
        app_manager.connect("purchase-requested", self._on_purchase_requested)
        app_manager.buy_app(app)
        self.assertTrue(self._purchase_requested_signal)
        do_events()
 def test_add_where_is_it(self):
     app = Application("", "software-center")
     self.view.show_app(app)
     self.view._add_where_is_it_commandline("apt")
     do_events()
     self.view._add_where_is_it_launcher("/usr/share/applications/ubuntu-software-center.desktop")
     do_events()
Beispiel #10
0
 def _inline_add_repo_call(self):
     deb_line = "deb https://foo"
     signing_key_id = u"xxx"
     app = Application(u"Elementals: The Magic Key™", "pkgname")
     iconname = "iconname"
     yield self.aptd.add_repo_add_key_and_install_app(
         deb_line, signing_key_id, app, iconname, None, None)
 def test_not_automatic_version(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     normal_version = self._make_version(not_automatic=False)
     not_automatic_version = self._make_version(not_automatic=True)
     details._pkg.versions = [normal_version, not_automatic_version]
     # force not-automatic with invalid data
     self.assertRaises(ValueError,
                       details.force_not_automatic_archive_suite,
                       "random-string")
     # force not-automatic with valid data
     self.assertTrue(
         details.force_not_automatic_archive_suite(
             not_automatic_version.origins[0].archive))
     # ensure we get the description of the not-automatic version
     self.assertEqual(details.description,
                      not_automatic_version.description)
     self.assertEqual(details.summary, not_automatic_version.summary)
     self.assertEqual(details.version, not_automatic_version.version)
     self.assertEqual(app.archive_suite,
                      not_automatic_version.origins[0].archive)
     # clearing works
     details.force_not_automatic_archive_suite("")
     self.assertEqual(app.archive_suite, "")
Beispiel #12
0
 def test_install_appdetails(self):
     win = get_test_window_appdetails()
     self.addCleanup(win.destroy)
     view = win.get_data("view")
     view.show_app(Application("", "2vcard"))
     view.backend.emit('transaction-progress-changed',
                       view.app_details.pkgname, 10)
     self.assertTrue(view.pkg_statusbar.progress.get_property("visible"))
Beispiel #13
0
    def setUp(self):
        self.win = get_test_window_appdetails()
        self.addCleanup(self.win.destroy)
        self.view = self.win.get_data("view")

        app = Application("", self.app_name)
        self.app_mock = get_mock_app_from_real_app(app)
        self.app_mock.details.pkg_state = self.pkg_state
Beispiel #14
0
    def test_submit_new_review_disables_button(self, mock_run):
        app = Application("", "2vcard")
        self.view.show_app(app)
        button = self.view.reviews.new_review
        self.assertTrue(button.is_sensitive())

        button.emit('clicked')

        self.assertFalse(button.is_sensitive())
Beispiel #15
0
    def set_mock_app_and_details(self, app_name="software-center", **kwargs):
        app = Application("", app_name)
        mock_app = get_mock_app_from_real_app(app)
        mock_details = mock_app.get_details(None)
        for attr, value in kwargs.iteritems():
            setattr(mock_details, attr, value)

        self.view.app = mock_app
        self.view.app_details = mock_details
Beispiel #16
0
    def test_non_axi_apps_cataloged_time(self):
        db = xapian.WritableDatabase("./data/test.db", 
                                     xapian.DB_CREATE_OR_OVERWRITE)
        res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
        self.assertTrue(res)
        db = StoreDatabase("./data/test.db", self.cache)
        db.open(use_axi=True)

        axi_value_time = db._axi_values["catalogedtime"]
        sc_app = Application("Ubuntu Software Center Test", "software-center")
        sc_doc = db.get_xapian_document(sc_app.appname, sc_app.pkgname)
        sc_cataloged_time = sc_doc.get_value(axi_value_time)
        so_app = Application("Scintillant Orange", "scintillant-orange")
        so_doc = db.get_xapian_document(so_app.appname, so_app.pkgname)
        so_cataloged_time = so_doc.get_value(axi_value_time)
        # the test package Scintillant Orange should be cataloged at a
        # later time than axi package Ubuntu Software Center
        self.assertTrue(so_cataloged_time > sc_cataloged_time)
Beispiel #17
0
 def test_appdetails(self):
     app = Application("Foo app", "dpkg")
     db = get_test_db()
     appdetails = app.get_details(db)
     # patching properties is a bit cumbersome
     with patch.object(AppDetails, "raw_price") as mock_price:
         with patch.object(AppDetails, "currency") as mock_currency:
             mock_price.__get__ = Mock(return_value="2.99")
             mock_currency.__get__ = Mock(return_value="USD")
             self.assertEqual("USD 2.99", appdetails.price)
 def test_install_appdetails(self):
     from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
     win = get_test_window_appdetails()
     view = win.get_data("view")
     view.show_app(Application("", "2vcard"))
     self._p()
     app = view.app
     view.backend.install(app, "")
     self._p()
     self.assertTrue(view.pkg_statusbar.progress.get_property("visible"))
Beispiel #19
0
    def _navigate_to_appdetails_and_install(self, pkgname):
        app = Application("", pkgname)
        available_pane.app_view.emit("application-activated", app)
        self._p()

        # pretend we started an install
        available_pane.backend.emit("transaction-started", app.pkgname,
                                    app.appname, "testid101",
                                    TransactionTypes.INSTALL)
        # wait a wee bit
        self._zzz()
 def test_app_icon_loading(self):
     # get icon
     app = Application("", "software-center")
     mock_app = get_mock_app_from_real_app(app)
     self.view.app = mock_app
     mock_details = mock_app.get_details(None)
     mock_details.cached_icon_file_path = "download-icon-test"
     mock_details.icon = "favicon.ico"
     mock_details.icon_url = "http://de.wikipedia.org/favicon.ico"
     self.view.app_details = mock_details
     self.view.show_app(mock_app)
     do_events()
Beispiel #21
0
 def disabled_for_now_test_where_is_it_in_system(self):
     app = Application("Hardware Drivers", "jockey-gtk")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file,
                      "/usr/share/app-install/desktop/jockey-gtk.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file)
     self.assertEqual(found[0].get_name(), "Desktop")
     self.assertEqual(found[0].get_icon(), "preferences-other")
     self.assertEqual(found[1].get_name(), "Administration")
     self.assertEqual(found[1].get_icon(), "preferences-system")
 def test_not_automatic_channel_support(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     versions = [
         self._make_version(not_automatic=True),
         self._make_version(not_automatic=False)
     ]
     details._pkg.versions = versions
     details._pkg.candidate = versions[1]
     self.assertEqual(details.get_not_automatic_archive_versions(),
                      [(versions[1].version, "precise"),
                       (versions[0].version, "precise-backports")])
 def test_package_states(self):
     db = xapian.WritableDatabase(TEST_DB, xapian.DB_CREATE_OR_OVERWRITE)
     res = update_from_app_install_data(db,
                                        self.cache,
                                        datadir=os.path.join(
                                            DATA_DIR, "desktop"))
     self.assertTrue(res)
     db = StoreDatabase(TEST_DB, self.cache)
     db.open(use_axi=False)
     # test PkgStates.INSTALLED
     # FIXME: this will only work if software-center is installed
     app = Application("Ubuntu Software Center Test", "software-center")
     appdetails = app.get_details(db)
     self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED,
                                              PkgStates.UPGRADABLE))
     # test PkgStates.UNINSTALLED
     # test PkgStates.UPGRADABLE
     # test PkgStates.REINSTALLABLE
     # test PkgStates.INSTALLING
     # test PkgStates.REMOVING
     # test PkgStates.UPGRADING
     # test PkgStates.NEEDS_SOURCE
     app = Application("Zynjacku Test", "zynjacku-fake")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_SOURCE)
     # test PkgStates.NEEDS_PURCHASE
     app = Application("The expensive gem", "expensive-gem")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NEEDS_PURCHASE)
     self.assertEqual(appdetails.icon_url,
                      "http://www.google.com/favicon.ico")
     self.assertEqual(appdetails.icon, "expensive-gem-icon-favicon")
     # test PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED
     # test PkgStates.UNKNOWN
     app = Application("Scintillant Orange", "scintillant-orange")
     appdetails = app.get_details(db)
     self.assertEqual(appdetails.pkg_state, PkgStates.NOT_FOUND)
     expected = ['use::converting', 'role::program', 'implemented-in::perl']
     self.assertEqual(appdetails.tags, set(expected))
    def test_videoplayer(self):
        # get the widget
        win = get_test_window_appdetails()
        view = win.get_data("view")

        # show app with no video
        app = Application("", "2vcard")
        view.show_app(app)
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertFalse(view.videoplayer.get_property("visible"))

        # create app with video and ensure its visible
        app = Application("", "synaptic")
        mock = get_mock_app_from_real_app(app)
        details = mock.get_details(None)
        # this is a example html - any html5 video will do
        details.video_url = "http://people.canonical.com/~mvo/totem.html"
        view.show_app(mock)
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertTrue(view.videoplayer.get_property("visible"))
Beispiel #25
0
 def test_where_is_it_real_system(self):
     app = Application("", "gedit")
     details = app.get_details(self.db)
     if details.pkg_state != PkgStates.INSTALLED:
         logging.warn("gedit not installed, skipping real menu test")
         self.skipTest("gedit not installed")
         return
     self.assertEqual(details.desktop_file,
                      "/usr/share/app-install/desktop/gedit:gedit.desktop")
     # search the *real* menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file)
     self.assertNotEqual(found, None)
 def test_multiple_version_pkg_states(self):
     db = get_test_db()
     app = Application("", "software-center")
     details = app.get_details(db)
     normal_version = self._make_version(not_automatic=False)
     not_automatic_version = self._make_version(not_automatic=True)
     details._pkg.versions = [normal_version, not_automatic_version]
     details._pkg.installed = normal_version
     details._pkg.is_installed = True
     # disabled for now
     #details._pkg.is_upgradable = True
     self.assertEqual(details.pkg_state, PkgStates.INSTALLED)
     app.archive_suite = not_automatic_version
     self.assertEqual(details.pkg_state, PkgStates.FORCE_VERSION)
Beispiel #27
0
 def _install_from_list_view(self, pkgname):
     from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
     available_pane.notebook.set_current_page(AvailablePane.Pages.LIST)
     self._p()
     available_pane.on_search_terms_changed(None,
                                            "ark,artha,software-center")
     self._p()
     # select the first item in the list
     available_pane.app_view.tree_view.set_cursor(Gtk.TreePath(0), None,
                                                  False)
     # ok to just use the test app here
     app = Application("", pkgname)
     self._p()
     self._simulate_install_events(app)
Beispiel #28
0
    def test_leave_page_stops_video(self):
        called = []

        self.pane.state.application = Application('', 'foo')
        self.vm.display_page(self.pane, self.pane.Pages.DETAILS,
                             self.pane.state)
        assert self.pane.is_app_details_view_showing()

        self.pane.app_details_view.videoplayer.stop = \
            lambda: called.append('stop')

        self.pane.leave_page(self.pane.state)

        self.assertEqual(called, ['stop'])
Beispiel #29
0
 def test_unity_launcher_integration_cancelled_install(
         self, mock_cancel_launcher):
     # test the automatic add to launcher enabled functionality when
     # installing an app from the details view, and then cancelling
     # the install (see LP: #1027209)
     self.config.add_to_unity_launcher = True
     test_pkgname = "software-center"
     app = Application("", test_pkgname)
     self.available_pane.app_view.emit("application-activated", app)
     do_events()
     self._simulate_install_events(app,
                                   result_event="transaction-cancelled")
     # ensure that we cancel the send
     self.assertTrue(mock_cancel_launcher.called)
Beispiel #30
0
    def test_videoplayer(self):
        # show app with no video
        app = Application("", "2vcard")
        self.view.show_app(app)
        do_events()
        self.assertFalse(self.view.videoplayer.get_property("visible"))

        # create app with video and ensure its visible
        self.set_mock_app_and_details(
            app_name="synaptic",
            # this is a example html - any html5 video will do
            video_url="http://people.canonical.com/~mvo/totem.html")
        self.view.show_app(self.view.app)
        do_events()
        self.assertTrue(self.view.videoplayer.get_property("visible"))