def get_test_window():
    from softwarecenter.testutils import (get_test_db,
                                          get_test_datadir,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()

    w = InstalledPane(cache, db, 'Ubuntu', icons, datadir)
    w.show()

    win = Gtk.Window()
    win.set_data("pane", w)
    win.add(w)
    win.set_size_request(400, 600)
    win.connect("destroy", lambda x: Gtk.main_quit())

    # init the view
    w.init_view()

    from softwarecenter.backend.channel import AllInstalledChannel
    w.state.channel = AllInstalledChannel()
    w.display_overview_page(None, None)

    win.show()
    return win
示例#2
0
def get_test_window():
    from softwarecenter.testutils import (get_test_db, get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          get_test_enquirer_matches)
    from softwarecenter.ui.gtk3.models.appstore2 import AppListStore

    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create the view
    appview = AppView(db, cache, icons, show_ratings=True)
    liststore = AppListStore(db, cache, icons)
    appview.set_model(liststore)

    # do a simple query and display that
    appview.display_matches(get_test_enquirer_matches(db))

    # and put it in the window
    win = Gtk.Window()
    win.add(appview)
    win.set_data("appview", appview)

    win.connect("destroy", lambda x: Gtk.main_quit())
    win.set_size_request(600, 400)
    win.show_all()

    return win
示例#3
0
def get_test_window_viewswitcher():
    from softwarecenter.testutils import (get_test_db,
                                          get_test_datadir,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()
    datadir = get_test_datadir()
    manager = get_test_gtk3_viewmanager()

    view = ViewSwitcher(manager, datadir, db, cache, icons)

    scroll = Gtk.ScrolledWindow()
    box = Gtk.VBox()
    box.pack_start(scroll, True, True, 0)

    win = Gtk.Window()
    scroll.add_with_viewport(view)

    win.add(box)
    win.set_size_request(400,200)
    win.connect("destroy", Gtk.main_quit)
    win.show_all()
    return win
示例#4
0
def get_test_window():
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    # this is *way* to complicated we should *not* need a CatView
    # here! see FIXME in RecommendationsPanel.__init__()
    from softwarecenter.ui.gtk3.views.catview_gtk import CategoriesViewGtk
    from softwarecenter.testutils import (
        get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache)
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()
    catview = CategoriesViewGtk(softwarecenter.paths.datadir,
                                softwarecenter.paths.APP_INSTALL_PATH,
                                cache,
                                db,
                                icons)

    view = RecommendationsPanelLobby(catview)

    win = Gtk.Window()
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.add(view)
    win.set_data("rec_panel", view)
    win.set_size_request(600, 200)
    win.show_all()

    return win
示例#5
0
def get_test_window_viewswitcher():
    from softwarecenter.testutils import (
        get_test_db,
        get_test_datadir,
        get_test_gtk3_viewmanager,
        get_test_pkg_info,
        get_test_gtk3_icon_cache,
    )
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()
    datadir = get_test_datadir()
    manager = get_test_gtk3_viewmanager()

    view = ViewSwitcher(manager, datadir, db, cache, icons)

    scroll = Gtk.ScrolledWindow()
    box = Gtk.VBox()
    box.pack_start(scroll, True, True, 0)

    win = Gtk.Window()
    scroll.add_with_viewport(view)

    win.add(box)
    win.set_size_request(400, 200)
    win.connect("destroy", Gtk.main_quit)
    win.show_all()
    return win
示例#6
0
def get_test_window():

    from softwarecenter.testutils import (get_test_db,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    widget = HistoryPane(cache, db, None, icons, None)
    widget.show()

    win = Gtk.Window()
    win.add(widget)
    win.set_size_request(600, 500)
    win.set_position(Gtk.WindowPosition.CENTER)
    win.show_all()
    win.connect('destroy', Gtk.main_quit)

    widget.init_view()
    return win
示例#7
0
    def disabled_test_for_purchase_apps_cataloged_time(self):
        from softwarecenter.testutils import get_test_pkg_info
        #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
        os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
        # staging does not have a valid cert
        os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
        cache = get_test_pkg_info()
        db = xapian.WritableDatabase("./data/test.db",
                                     xapian.DB_CREATE_OR_OVERWRITE)
        res = update_from_software_center_agent(db, cache, ignore_cache=True)
        self.assertTrue(res)
        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)
        for_purch_app = Application("For Purchase Test App", "hellox")
        for_purch_doc = db.get_xapian_document(for_purch_app.appname,
                                               for_purch_app.pkgname)
        for_purch_cataloged_time = for_purch_doc.get_value(axi_value_time)
        # the for-purchase test package should be cataloged at a
        # later time than axi package Ubuntu Software Center
        self.assertTrue(for_purch_cataloged_time > sc_cataloged_time)

        del os.environ["SOFTWARE_CENTER_AGENT_HOST"]
示例#8
0
def get_test_window():
    from softwarecenter.testutils import (
        get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache,
        get_test_enquirer_matches)
    from softwarecenter.ui.gtk3.models.appstore2 import AppListStore

    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create the view
    appview = AppView(db, cache, icons, show_ratings=True)
    liststore = AppListStore(db, cache, icons)
    appview.set_model(liststore)

    # do a simple query and display that
    appview.display_matches(get_test_enquirer_matches(db))

    # and put it in the window
    win = Gtk.Window()
    win.add(appview)
    win.set_data("appview", appview)

    win.connect("destroy", lambda x: Gtk.main_quit())
    win.set_size_request(600, 400)
    win.show_all()

    return win
示例#9
0
def get_test_window():
    from softwarecenter.testutils import (
        get_test_db,
        get_test_datadir,
        get_test_gtk3_viewmanager,
        get_test_pkg_info,
        get_test_gtk3_icon_cache,
    )

    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()

    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back", "Back", None)
    navhistory_forward_action = Gtk.Action("navhistory_forward_action", "Forward", "Forward", None)

    w = AvailablePane(cache, db, "Ubuntu", icons, datadir, navhistory_back_action, navhistory_forward_action)
    w.init_view()
    w.show()

    win = Gtk.Window()
    win.connect("destroy", Gtk.main_quit)
    win.add(w)
    win.set_size_request(800, 600)
    win.show_all()

    # this is used later in tests
    win.set_data("pane", w)

    return win
def get_test_window():

    from softwarecenter.testutils import (
        get_test_db,
        get_test_gtk3_viewmanager,
        get_test_pkg_info,
        get_test_gtk3_icon_cache,
    )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    widget = HistoryPane(cache, db, None, icons, None)
    widget.show()

    win = Gtk.Window()
    win.add(widget)
    win.set_size_request(600, 500)
    win.set_position(Gtk.WindowPosition.CENTER)
    win.show_all()
    win.connect('destroy', Gtk.main_quit)

    widget.init_view()
    return win
def get_test_window(panel_type="lobby"):
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    # this is *way* too complicated we should *not* need a CatView
    # here! see FIXME in RecommendationsPanel.__init__()
    from softwarecenter.ui.gtk3.views.catview_gtk import CategoriesViewGtk
    from softwarecenter.testutils import (get_test_db, get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          get_test_categories)
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()
    catview = CategoriesViewGtk(softwarecenter.paths.datadir,
                                softwarecenter.paths.APP_INSTALL_PATH, cache,
                                db, icons)

    if panel_type is "lobby":
        view = RecommendationsPanelLobby(catview)
    elif panel_type is "category":
        cats = get_test_categories(db)
        view = RecommendationsPanelCategory(catview, cats[0])
    else:  # panel_type is "details":
        view = RecommendationsPanelDetails(catview)

    win = Gtk.Window()
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.add(view)
    win.set_data("rec_panel", view)
    win.set_size_request(600, 200)
    win.show_all()

    return win
示例#12
0
def get_test_window():
    from softwarecenter.testutils import (
        get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache)
    from softwarecenter.db.enquire import AppEnquire
    from softwarecenter.ui.gtk3.models.appstore2 import AppListStore
    import xapian

    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create the view
    appview = AppView(db, cache, icons, show_ratings=True)
    liststore = AppListStore(db, cache, icons)
    appview.set_model(liststore)

    # do a simple query and display that
    enquirer = AppEnquire(cache, db)
    enquirer.set_query(xapian.Query(""),
                       sortmode=SortMethods.BY_CATALOGED_TIME,
                       limit=20,
                       nonblocking_load=False)
    appview.display_matches(enquirer.matches)

    # and put it in the window
    win = Gtk.Window()
    win.add(appview)
    win.set_data("appview", appview)

    win.connect("destroy", lambda x: Gtk.main_quit())
    win.set_size_request(600, 400)
    win.show_all()

    return win
示例#13
0
 def test_license_string_data_from_software_center_agent(self):
     # os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
     # os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
     # staging does not have a valid cert
     os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
     cache = get_test_pkg_info()
     db = xapian.WritableDatabase("./data/test.db", xapian.DB_CREATE_OR_OVERWRITE)
     res = update_from_software_center_agent(db, cache, ignore_cache=True)
     self.assertTrue(res)
     for p in db.postlist(""):
         doc = db.get_document(p.docid)
         license = doc.get_value(XapianValues.LICENSE)
         self.assertNotEqual(license, "")
         self.assertNotEqual(license, None)
 def test_license_string_data_from_software_center_agent(self):
     #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
     #os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
     # staging does not have a valid cert
     os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
     cache = get_test_pkg_info()
     db = xapian.WritableDatabase("./data/test.db",
                                  xapian.DB_CREATE_OR_OVERWRITE)
     res = update_from_software_center_agent(db, cache, ignore_cache=True)
     self.assertTrue(res)
     for p in db.postlist(""):
         doc = db.get_document(p.docid)
         license = doc.get_value(XapianValues.LICENSE)
         self.assertNotEqual(license, "")
         self.assertNotEqual(license, None)
示例#15
0
def get_test_window():
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    softwarecenter.log.add_filters_from_string("performance")
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    from softwarecenter.testutils import (
        get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache,
        get_test_categories)

    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    from softwarecenter.db.appfilter import AppFilter
    filter = AppFilter(db, cache)
    filter.set_supported_only(False)
    filter.set_installed_only(True)

    # get the TREEstore
    from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore
    store = AppTreeStore(db, cache, icons)

    # populate from data
    cats = get_test_categories(db)
    for cat in cats[:3]:
        with ExecutionTime("query cat '%s'" % cat.name):
            docs = db.get_docs_from_query(cat.query)
            store.set_category_documents(cat, docs)

    # ok, this is confusing - the AppView contains the AppTreeView that
    #                         is a tree or list depending on the model
    from softwarecenter.ui.gtk3.views.appview import AppView
    app_view = AppView(db, cache, icons, show_ratings=True)
    app_view.set_model(store)

    box = Gtk.VBox()
    box.pack_start(app_view, True, True, 0)

    win = Gtk.Window()
    win.add(box)
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.set_size_request(600, 400)
    win.show_all()

    return win
示例#16
0
def get_test_window():
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    softwarecenter.log.add_filters_from_string("performance")
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    from softwarecenter.testutils import (get_test_db, get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          get_test_categories)

    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    from softwarecenter.db.appfilter import AppFilter
    filter = AppFilter(db, cache)
    filter.set_supported_only(False)
    filter.set_installed_only(True)

    # get the TREEstore
    from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore
    store = AppTreeStore(db, cache, icons)

    # populate from data
    cats = get_test_categories(db)
    for cat in cats[:3]:
        with ExecutionTime("query cat '%s'" % cat.name):
            docs = db.get_docs_from_query(cat.query)
            store.set_category_documents(cat, docs)

    # ok, this is confusing - the AppView contains the AppTreeView that
    #                         is a tree or list depending on the model
    from softwarecenter.ui.gtk3.views.appview import AppView
    app_view = AppView(db, cache, icons, show_ratings=True)
    app_view.set_model(store)

    box = Gtk.VBox()
    box.pack_start(app_view, True, True, 0)

    win = Gtk.Window()
    win.add(box)
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.set_size_request(600, 400)
    win.show_all()

    return win
示例#17
0
def get_test_window():
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    softwarecenter.log.add_filters_from_string("performance")
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    from softwarecenter.testutils import (
        get_test_db, get_test_pkg_info, get_test_gtk3_icon_cache)
    from softwarecenter.ui.gtk3.models.appstore2 import AppListStore

    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    from softwarecenter.db.appfilter import AppFilter
    filter = AppFilter(db, cache)
    filter.set_supported_only(False)
    filter.set_installed_only(True)

    # appview
    from softwarecenter.db.enquire import AppEnquire
    enquirer = AppEnquire(cache, db)
    store = AppListStore(db, cache, icons)

    from softwarecenter.ui.gtk3.views.appview import AppView
    view = AppView(db, cache, icons, show_ratings=True)
    view.set_model(store)

    entry = Gtk.Entry()
    entry.stamp = 0
    entry.connect("changed", on_entry_changed, (view, enquirer))

    box = Gtk.VBox()
    box.pack_start(entry, False, True, 0)
    box.pack_start(view, True, True, 0)

    win = Gtk.Window()
    win.set_data("appview", view)
    win.set_data("entry", entry)
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.add(box)
    win.set_size_request(600, 400)
    win.show_all()

    return win
def get_test_window():
    import softwarecenter.log
    softwarecenter.log.root.setLevel(level=logging.DEBUG)
    softwarecenter.log.add_filters_from_string("performance")
    fmt = logging.Formatter("%(name)s - %(message)s", None)
    softwarecenter.log.handler.setFormatter(fmt)

    from softwarecenter.testutils import (get_test_db, get_test_pkg_info,
                                          get_test_gtk3_icon_cache)
    from softwarecenter.ui.gtk3.models.appstore2 import AppListStore

    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    from softwarecenter.db.appfilter import AppFilter
    filter = AppFilter(db, cache)
    filter.set_supported_only(False)
    filter.set_installed_only(True)

    # appview
    from softwarecenter.db.enquire import AppEnquire
    enquirer = AppEnquire(cache, db)
    store = AppListStore(db, cache, icons)

    from softwarecenter.ui.gtk3.views.appview import AppView
    view = AppView(db, cache, icons, show_ratings=True)
    view.set_model(store)

    entry = Gtk.Entry()
    entry.stamp = 0
    entry.connect("changed", on_entry_changed, (view, enquirer))

    box = Gtk.VBox()
    box.pack_start(entry, False, True, 0)
    box.pack_start(view, True, True, 0)

    win = Gtk.Window()
    win.set_data("appview", view)
    win.set_data("entry", entry)
    win.connect("destroy", lambda x: Gtk.main_quit())
    win.add(box)
    win.set_size_request(600, 400)
    win.show_all()

    return win
    def test_for_purchase_apps_date_published(self):
        from softwarecenter.testutils import get_test_pkg_info
        #os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
        #os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
        # staging does not have a valid cert
        os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
        cache = get_test_pkg_info()
        db = xapian.WritableDatabase("./data/test.db",
                                     xapian.DB_CREATE_OR_OVERWRITE)
        res = update_from_software_center_agent(db, cache, ignore_cache=True)
        self.assertTrue(res)

        for p in db.postlist(""):
            doc = db.get_document(p.docid)
            date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
            # make sure that a date_published value is provided
            self.assertNotEqual(date_published, "")
            self.assertNotEqual(date_published, None)
示例#20
0
    def test_for_purchase_apps_date_published(self):
        from softwarecenter.testutils import get_test_pkg_info

        # os.environ["SOFTWARE_CENTER_DEBUG_HTTP"] = "1"
        # os.environ["SOFTWARE_CENTER_AGENT_HOST"] = "http://sc.staging.ubuntu.com/"
        # staging does not have a valid cert
        os.environ["PISTON_MINI_CLIENT_DISABLE_SSL_VALIDATION"] = "1"
        cache = get_test_pkg_info()
        db = xapian.WritableDatabase("./data/test.db", xapian.DB_CREATE_OR_OVERWRITE)
        res = update_from_software_center_agent(db, cache, ignore_cache=True)
        self.assertTrue(res)

        for p in db.postlist(""):
            doc = db.get_document(p.docid)
            date_published = doc.get_value(XapianValues.DATE_PUBLISHED)
            # make sure that a date_published value is provided
            self.assertNotEqual(date_published, "")
            self.assertNotEqual(date_published, None)
def get_test_window():
    from softwarecenter.testutils import (
        get_test_db,
        get_test_datadir,
        get_test_install_backend,
        get_test_gtk3_viewmanager,
        get_test_pkg_info,
        get_test_gtk3_icon_cache,
    )
    # needed because available pane will try to get it
    vm = get_test_gtk3_viewmanager()
    vm  # make pyflakes happy
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()
    backend = get_test_install_backend()

    # create global AppManager instance
    from softwarecenter.ui.gtk3.session.appmanager import ApplicationManager
    ApplicationManager(db, backend, icons)

    navhistory_back_action = Gtk.Action("navhistory_back_action", "Back",
                                        "Back", None)
    navhistory_forward_action = Gtk.Action("navhistory_forward_action",
                                           "Forward", "Forward", None)

    w = AvailablePane(cache, db, 'Ubuntu', icons, datadir,
                      navhistory_back_action, navhistory_forward_action)
    w.init_view()
    w.show()

    win = Gtk.Window()
    win.connect("destroy", Gtk.main_quit)
    win.add(w)
    win.set_size_request(800, 600)
    win.show_all()

    # this is used later in tests
    win.set_data("pane", w)

    return win
示例#22
0
def get_test_window():

    from softwarecenter.testutils import (get_test_db,
                                          get_test_datadir,
                                          get_test_gtk3_viewmanager,
                                          get_test_pkg_info,
                                          get_test_gtk3_icon_cache,
                                          )
    vm = get_test_gtk3_viewmanager()
    db = get_test_db()
    cache = get_test_pkg_info()
    datadir = get_test_datadir()
    icons = get_test_gtk3_icon_cache()

    p = GlobalPane(vm, datadir, db, cache, icons)

    win = Gtk.Window()
    win.connect("destroy", Gtk.main_quit)
    win.add(p)
    win.show_all()
    return win
    def test_app_enquire(self):
        db = get_test_db()
        cache = get_test_pkg_info()

        xfilter = AppFilter(cache, db)
        enquirer = AppEnquire(cache, db)
        terms = [
            "app", "this", "the", "that", "foo", "tool", "game", "graphic",
            "ubuntu", "debian", "gtk", "this", "bar", "baz"
        ]

        # run a bunch of the querries in parallel
        for nonblocking in [False, True]:
            for i in range(10):
                for term in terms:
                    enquirer.set_query(search_query=xapian.Query(term),
                                       limit=0,
                                       filter=xfilter,
                                       nonblocking_load=nonblocking)
        # give the threads a bit of time
        time.sleep(5)
示例#24
0
    def test_app_enquire(self):
        db = get_test_db()
        cache = get_test_pkg_info()

        xfilter = AppFilter(cache, db)
        enquirer = AppEnquire(cache, db)
        terms = [ "app", "this", "the", "that", "foo", "tool", "game", 
                  "graphic", "ubuntu", "debian", "gtk", "this", "bar", 
                  "baz"]

        # run a bunch of the querries in parallel
        for nonblocking in [False, True]:
            for i in range(10):
                for term in terms:
                    enquirer.set_query(
                        search_query=xapian.Query(term),
                        limit=0,
                        filter=xfilter,
                        nonblocking_load=nonblocking)
        # give the threads a bit of time
        time.sleep(5)
class TestReviewLoader(unittest.TestCase):
    cache = get_test_pkg_info()
    db = get_test_db()

    def _review_stats_ready_callback(self, review_stats):
        self._stats_ready = True
        self._review_stats = review_stats


#    def test_review_stats_caching(self):
#        self._stats_ready = False
#        self._review_stats = []
#        review_loader = ReviewLoader(self.cache, self.db)
#        review_loader.refresh_review_stats(self._review_stats_ready_callback)
#        while not self._stats_ready:
#            self._p()
#        self.assertTrue(len(self._review_stats) > 0)
#        self.assertTrue(os.path.exists(review_loader.REVIEW_STATS_CACHE_FILE))
#        self.assertTrue(os.path.exists(review_loader.REVIEW_STATS_BSDDB_FILE))
#        # once its there, get_top_rated
#        top_rated = review_loader.get_top_rated_apps(quantity=10)
#        self.assertEqual(len(top_rated), 10)
#        # and per-cat
#        top_cat = review_loader.get_top_rated_apps(
#            quantity=8, category="Internet")
#        self.assertEqual(len(top_cat), 8)

    def test_edit_review_screen_has_right_labels(self):
        """Check that LP #880255 stays fixed. """

        review_app = SubmitReviewsApp(datadir="../data",
                                      app=None,
                                      parent_xid='',
                                      iconname='accessories-calculator',
                                      origin=None,
                                      version=None,
                                      action='modify',
                                      review_id=10000)
        # monkey patch away login to avoid that we actually login
        # and the UI changes because of that

        review_app.login = lambda: True

        # run the main app
        review_app.run()

        self._p()
        review_app.login_successful('foobar')
        self._p()
        self.assertEqual(_('Rating:'), review_app.rating_label.get_label())
        self.assertEqual(_('Summary:'),
                         review_app.review_summary_label.get_label())
        self.assertEqual(
            _('Review by: %s') % 'foobar', review_app.review_label.get_label())
        review_app.submit_window.hide()

    def test_get_fade_colour_markup(self):
        review_app = SubmitReviewsApp(datadir="../data",
                                      app=None,
                                      parent_xid='',
                                      iconname='accessories-calculator',
                                      origin=None,
                                      version=None,
                                      action='nothing')
        cases = (
            (('006000', '00A000', 40, 60, 50), ('008000', 10)),
            (('000000', 'FFFFFF', 40, 40, 40), ('000000', 0)),
            (('000000', '808080', 100, 400, 40), ('000000', 360)),
            (('000000', '808080', 100, 400, 1000), ('808080', -600)),
            (('123456', '5294D6', 10, 90, 70), ('427CB6', 20)),
        )
        for args, return_value in cases:
            result = review_app._get_fade_colour_markup(*args)
            expected = '<span fgcolor="#%s">%s</span>' % return_value
            self.assertEqual(expected, result)

    def test_modify_review_is_the_same_supports_unicode(self):
        review_app = SubmitReviewsApp(datadir="../data",
                                      app=None,
                                      parent_xid='',
                                      iconname='accessories-calculator',
                                      origin=None,
                                      version=None,
                                      action='modify',
                                      review_id=10000)
        self.assertTrue(review_app._modify_review_is_the_same())

        cases = ('', 'e', ')!')
        for case in cases:
            modified = review_app.orig_summary_text[:-1] + case
            review_app.review_summary_entry.set_text(modified)
            self.assertFalse(review_app._modify_review_is_the_same())

        review_app.review_summary_entry.set_text(review_app.orig_summary_text)
        for case in cases:
            modified = review_app.orig_review_text[:-1] + case
            review_app.review_buffer.set_text(modified)
            self.assertFalse(review_app._modify_review_is_the_same())

    def test_change_status(self):
        review_app = SubmitReviewsApp(datadir="../data",
                                      app=None,
                                      parent_xid='',
                                      iconname='accessories-calculator',
                                      origin=None,
                                      version=None,
                                      action='nothing')
        msg = 'Something completely different'
        cases = {
            'clear': (True, True, True, True, None, None),
            'progress': (False, True, True, True, msg, None),
            'fail': (True, False, True, True, None, msg),
            'success': (True, True, False, True, msg, None),
            'warning': (True, True, True, False, msg, None),
        }
        review_app.run()

        for status in cases:
            review_app._change_status(status, msg)
            spinner, error, success, warn, label, error_detail = cases[status]
            self.assertEqual(spinner,
                             review_app.submit_spinner.get_parent() is None)
            self.assertEqual(error,
                             review_app.submit_error_img.get_window() is None)
            self.assertEqual(
                success,
                review_app.submit_success_img.get_window() is None)
            self.assertEqual(warn,
                             review_app.submit_warn_img.get_window() is None)
            if label:
                self.assertEqual(label,
                                 review_app.label_transmit_status.get_text())
            if error_detail:
                buff = review_app.error_textview.get_buffer()
                self.assertEqual(
                    error_detail,
                    buff.get_text(buff.get_start_iter(),
                                  buff.get_end_iter(),
                                  include_hidden_chars=False))
                review_app.detail_expander.get_visible()

    def _p(self):
        main_loop = GObject.main_context_default()
        while main_loop.pending():
            main_loop.iteration()
示例#26
0
 def setUp(self):
     self.cache = get_test_pkg_info()
     self.db = get_test_db()
 def setUpClass(cls):
     cls.cache = get_test_pkg_info()
     cls.icons = get_test_gtk3_icon_cache()
     cls.db = get_test_db()
示例#28
0
 def setUp(self):
     self.cache = get_test_pkg_info()
     self.icons = get_test_gtk3_icon_cache()
     self.db = get_test_db()
示例#29
0
 def setUp(self):
     self.cache = get_test_pkg_info()
     self.icons = get_test_gtk3_icon_cache()
     self.db = get_test_db()
 def setUp(self):
     self.cache = get_test_pkg_info()
     self.db = get_test_db()