Ejemplo n.º 1
0
 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, "")
Ejemplo n.º 2
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 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_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, "")
Ejemplo n.º 5
0
    def __init__(self, debfile):
        if not is_deb_file(debfile):
            raise DebFileOpenError("Could not open %r." % debfile, debfile)

        # work out debname/appname
        debname = os.path.splitext(os.path.basename(debfile))[0]
        pkgname = debname.split('_')[0].lower()
        # call the constructor
        Application.__init__(self, pkgname=pkgname, request=debfile)
 def __init__(self, debfile):
     # sanity check
     if not debfile.endswith(".deb"):
         raise ValueError("Need a deb file, got '%s'" % debfile)
     # work out debname/appname
     debname = os.path.splitext(os.path.basename(debfile))[0]
     pkgname = debname.split('_')[0].lower()
     # call the constructor
     Application.__init__(self, pkgname=pkgname, request=debfile)
Ejemplo n.º 7
0
    def __init__(self, debfile):
        if not is_deb_file(debfile):
            raise DebFileOpenError("Could not open %r." % debfile, debfile)

        # work out debname/appname
        debname = os.path.splitext(os.path.basename(debfile))[0]
        pkgname = debname.split('_')[0].lower()
        # call the constructor
        Application.__init__(self, pkgname=pkgname, request=debfile)
Ejemplo n.º 8
0
 def __init__(self, debfile):
     # sanity check
     if not debfile.endswith(".deb"):
         raise ValueError("Need a deb file, got '%s'" % debfile)
     # work out debname/appname
     debname = os.path.splitext(os.path.basename(debfile))[0]
     pkgname = debname.split('_')[0].lower()
     # call the constructor
     Application.__init__(self, pkgname=pkgname, request=debfile)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
 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")],
     )
Ejemplo n.º 12
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)
Ejemplo n.º 13
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")
Ejemplo n.º 14
0
 def test_where_is_it_kde4(self):
     app = Application("", "ark")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file, "/usr/share/app-install/desktop/ark:kde4__ark.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(details.desktop_file, [os.path.abspath("./data/fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0], "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0], "applications-utilities")
Ejemplo n.º 15
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")
Ejemplo n.º 16
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)
Ejemplo n.º 17
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)
Ejemplo n.º 18
0
 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
     details._pkg.is_upgradable = True
     self.assertEqual(details.pkg_state, PkgStates.UPGRADABLE)
     app.archive_suite = not_automatic_version
     self.assertEqual(details.pkg_state, PkgStates.FORCE_VERSION)
 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 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_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)
 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))
Ejemplo n.º 23
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)
Ejemplo n.º 24
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)
Ejemplo n.º 25
0
 def test_where_is_it_kde4(self):
     app = Application("", "ark")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file,
                      "/usr/share/app-install/desktop/ark:kde4__ark.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(
         details.desktop_file,
         [os.path.join(DATA_DIR, "fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0],
                      "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0],
                      "applications-utilities")
 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()
Ejemplo n.º 27
0
 def get_exact_matches(self, pkgnames=[]):
     """ Returns a list of fake MSetItems. If the pkgname is available, then
         MSetItem.document is pkgnames proper xapian document. If the pkgname
         is not available, then MSetItem is actually an Application. """
     matches = []
     for pkgname in pkgnames:
         app = Application('', pkgname.split('?')[0])
         if '?' in pkgname:
             app.request = pkgname.split('?')[1]
         match = app
         for m in self.xapiandb.postlist("XP" + app.pkgname):
             match = self.xapiandb.get_document(m.docid)
         for m in self.xapiandb.postlist("AP" + app.pkgname):
             match = self.xapiandb.get_document(m.docid)
         matches.append(FakeMSetItem(match))
     return matches
 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)
Ejemplo n.º 29
0
 def get_exact_matches(self, pkgnames=[]):
     """ Returns a list of fake MSetItems. If the pkgname is available, then
         MSetItem.document is pkgnames proper xapian document. If the pkgname
         is not available, then MSetItem is actually an Application. """
     matches = []
     for pkgname in pkgnames:
         app = Application('', pkgname.split('?')[0])
         if '?' in pkgname:
             app.request = pkgname.split('?')[1]
         match = app
         for m in  self.xapiandb.postlist("XP"+app.pkgname):
             match = self.xapiandb.get_document(m.docid)
         for m in self.xapiandb.postlist("AP"+app.pkgname):
             match = self.xapiandb.get_document(m.docid)
         matches.append(FakeMSetItem(match))
     return matches        
    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"))
Ejemplo n.º 31
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()
Ejemplo n.º 32
0
 def test_where_is_it_in_applications(self):
     app = Application("Calculator", "gcalctool")
     details = app.get_details(self.db)
     self.assertEqual(details.desktop_file,
                      "/usr/share/app-install/desktop/gcalctool:gcalctool.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(
         details.desktop_file,
         [os.path.join(DATA_DIR, "fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0],
                      "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0],
                      "applications-utilities")
 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 test_where_is_it_in_applications(self):
     app = Application("Calculator", "gcalctool")
     details = app.get_details(self.db)
     self.assertEqual(
         details.desktop_file,
         "/usr/share/app-install/desktop/gcalctool:gcalctool.desktop")
     # search the settings menu
     searcher = GMenuSearcher()
     found = searcher.get_main_menu_path(
         details.desktop_file,
         [os.path.abspath("./data/fake-applications.menu")])
     self.assertEqual(found[0].get_name(), "Applications")
     self.assertEqual(found[0].get_icon().get_names()[0],
                      "applications-other")
     self.assertEqual(found[1].get_name(), "Accessories")
     self.assertEqual(found[1].get_icon().get_names()[0],
                      "applications-utilities")
Ejemplo n.º 35
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"))
Ejemplo n.º 36
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
Ejemplo n.º 37
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
Ejemplo n.º 38
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)
Ejemplo n.º 39
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())
 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"))
Ejemplo n.º 41
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()
    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"))
Ejemplo n.º 44
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'])
 def test_application_details(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, use_agent=False)
     self.assertEqual(len(db), 6)
     # test details
     app = Application("Ubuntu Software Center Test", "software-center")
     details = app.get_details(db)
     self.assertNotEqual(details, None)
     # mvo: disabled, we can reenable this once there is a static
     #      apt rootdir and we do not rely on the test system to
     #      have software-center from the main archive and not from
     #      e.g. a custom repo like the ADT environment
     # self.assertEqual(details.component, "main")
     self.assertEqual(details.pkgname, "software-center")
     # get the first document
     for doc in db:
         if doc.get_data() == "Ubuntu Software Center Test":
             appdetails = AppDetails(db, doc=doc)
             break
     # test get_appname and get_pkgname
     self.assertEqual(db.get_appname(doc), "Ubuntu Software Center Test")
     self.assertEqual(db.get_pkgname(doc), "software-center")
     # test appdetails
     self.assertEqual(appdetails.name, "Ubuntu Software Center Test")
     self.assertEqual(appdetails.pkgname, "software-center")
     # FIXME: add a dekstop file with a real channel to test
     #        and monkey-patch/modify the APP_INSTALL_CHANNELS_PATH
     self.assertEqual(appdetails.channelname, None)
     self.assertEqual(appdetails.channelfile, None)
     self.assertNotEqual(appdetails.pkg, None)
     # from the fake test/data/appdetails/var/lib/dpkg/status
     self.assertEqual(appdetails.pkg.is_installed, True)
     self.assertTrue(appdetails.pkg_state in (PkgStates.INSTALLED, PkgStates.UPGRADABLE))
     # FIXME: test description for unavailable pkg
     self.assertTrue(appdetails.description.startswith("Ubuntu Software Center lets you"))
     # FIXME: test appdetails.website
     self.assertEqual(appdetails.icon, "softwarecenter")
     # crude, crude
     self.assertTrue(len(appdetails.version) > 2)
     # FIXME: screenshots will only work on ubuntu
     self.assertTrue(
         re.match(
             "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+", appdetails.screenshot
         )
     )
     self.assertTrue(
         re.match(
             "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+", appdetails.thumbnail
         )
     )
     # FIXME: add document that has a price
     self.assertEqual(appdetails.price, "Free")
     self.assertEqual(appdetails.raw_price, "")
     # mvo: disabled, we can reenable this once there is a static
     #      apt rootdir and we do not rely on the test system to
     #      have software-center from the main archive and not from
     #      e.g. a custom repo like the ADT environment
     # self.assertEqual(appdetails.license, "Open source")
     # test lazy history loading for installation date
     self.ensure_installation_date_and_lazy_history_loading(appdetails)
     # test apturl replacements
     # $kernel
     app = Application("", "linux-headers-$kernel", "channel=$distro-partner")
     self.assertEqual(app.pkgname, "linux-headers-" + os.uname()[2])
     # $distro
     details = app.get_details(db)
     distro = softwarecenter.distro.get_distro().get_codename()
     self.assertEqual(app.request, "channel=" + distro + "-partner")
Ejemplo n.º 46
0
 def test_application_details(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, use_agent=False)
     self.assertEqual(len(db), 5)
     # test details
     app = Application("Ubuntu Software Center Test", "software-center")
     details = app.get_details(db)
     self.assertNotEqual(details, None)
     self.assertEqual(details.component, "main")
     self.assertEqual(details.pkgname, "software-center")
     # get the first document
     for doc in db:
         if doc.get_data() == "Ubuntu Software Center Test":
             appdetails = AppDetails(db, doc=doc)
             break
     # test get_appname and get_pkgname
     self.assertEqual(db.get_appname(doc), "Ubuntu Software Center Test")
     self.assertEqual(db.get_pkgname(doc), "software-center")
     # test appdetails
     self.assertEqual(appdetails.name, "Ubuntu Software Center Test")
     self.assertEqual(appdetails.pkgname, "software-center")
     # FIXME: add a dekstop file with a real channel to test
     #        and monkey-patch/modify the APP_INSTALL_CHANNELS_PATH
     self.assertEqual(appdetails.channelname, None)
     self.assertEqual(appdetails.channelfile, None)
     self.assertEqual(appdetails.component, "main")
     self.assertNotEqual(appdetails.pkg, None)
     # from the fake test/data/appdetails/var/lib/dpkg/status
     self.assertEqual(appdetails.pkg.is_installed, True)
     self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
     # FIXME: test description for unavailable pkg
     self.assertTrue(
         appdetails.description.startswith("Ubuntu Software Center lets you"))
     # FIXME: test appdetails.website
     self.assertEqual(appdetails.icon, "softwarecenter")
     # crude, crude
     self.assertTrue(len(appdetails.version) > 2)
     # FIXME: screenshots will only work on ubuntu
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+", 
             appdetails.screenshot))
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+",
             appdetails.thumbnail))
     # FIXME: add document that has a price
     self.assertEqual(appdetails.price, '')
     self.assertEqual(appdetails.license, "Open source")
     # test lazy history loading for installation date
     self.ensure_installation_date_and_lazy_history_loading(appdetails)
     # test apturl replacements
     # $kernel
     app = Application("", "linux-headers-$kernel", "channel=$distro-partner")
     self.assertEqual(app.pkgname, 'linux-headers-'+os.uname()[2])
     # $distro
     details = app.get_details(db)
     from softwarecenter.distro import get_distro
     distro = get_distro().get_codename()
     self.assertEqual(app.request, 'channel=' + distro + '-partner')