コード例 #1
0
 def test_regression_index_terms(self):
     """ this tests for a regression that we had in the term indexer
         that would index hundrets of size 1 terms due to a bug
         in AppInfoParserBase._set_doc_from_key
     """
     db = xapian.WritableDatabase(TEST_DB, xapian.DB_CREATE_OR_OVERWRITE)
     update_from_app_install_data(db, self.cache, datadir=os.path.join(DATA_DIR, "desktop"))
     for it in db.postlist("APsoftware-center"):
         docid = it.docid
         break
     # this is the important part, ensure no signle char terms
     for t in db.termlist(docid):
         self.assertFalse(len(t.term) == 1)
コード例 #2
0
 def test_regression_index_terms(self):
     """ this tests for a regression that we had in the term indexer
         that would index hundrets of size 1 terms due to a bug
         in AppInfoParserBase._set_doc_from_key
     """
     db = xapian.WritableDatabase(TEST_DB, xapian.DB_CREATE_OR_OVERWRITE)
     update_from_app_install_data(db,
                                  self.cache,
                                  datadir=os.path.join(DATA_DIR, "desktop"))
     for it in db.postlist("APsoftware-center"):
         docid = it.docid
         break
     # this is the important part, ensure no signle char terms
     for t in db.termlist(docid):
         self.assertFalse(len(t.term) == 1)
コード例 #3
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)
コード例 #4
0
 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))
コード例 #5
0
ファイル: test_database.py プロジェクト: cs2c/AppStream
    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"]
コード例 #6
0
ファイル: utils.py プロジェクト: sti-lyneos/shop
def get_test_db_from_app_install_data(datadir):
    db = xapian.inmemory_open()
    cache = get_pkg_info()
    cache.open()
    res = update_from_app_install_data(db, cache, datadir)
    if res is False:
        raise AssertionError("Failed to build db from '%s'" % datadir)
    return db
コード例 #7
0
ファイル: utils.py プロジェクト: pombredanne/shop
def get_test_db_from_app_install_data(datadir):
    db = xapian.inmemory_open()
    cache = get_pkg_info()
    cache.open()
    res = update_from_app_install_data(db, cache, datadir)
    if res is False:
        raise AssertionError("Failed to build db from '%s'" % datadir)
    return db
コード例 #8
0
 def _get_db_from_test_app_install_data(self):
     db = xapian.inmemory_open()
     res = update_from_app_install_data(db,
                                        self.cache,
                                        datadir=os.path.join(
                                            DATA_DIR, "desktop"))
     self.assertTrue(res)
     self.assertEqual(db.get_doccount(), 5)
     return db
コード例 #9
0
 def test_update_from_desktop_file(self):
     # ensure we index with german locales to test i18n
     os.environ["LANGUAGE"] = "de"
     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)
     self.assertEqual(db.get_doccount(), 5)
     # test if Name[de] was picked up
     i = 0
     for it in db.postlist("AAUbuntu Software Zentrum"):
         i += 1
     self.assertEqual(i, 1)
コード例 #10
0
 def test_update_from_desktop_file(self):
     # ensure we index with german locales to test i18n
     os.environ["LANGUAGE"] = "de"
     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)
     self.assertEqual(db.get_doccount(), 5)
     # test if Name[de] was picked up
     i=0
     for it in db.postlist("AAUbuntu Software Zentrum"):
         i+=1
     self.assertEqual(i, 1)
コード例 #11
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)
コード例 #12
0
 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))
コード例 #13
0
 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')
コード例 #14
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')
コード例 #15
0
 def _get_db_from_test_app_install_data(self):
     db = xapian.inmemory_open()
     res = update_from_app_install_data(db, self.cache, datadir=os.path.join(DATA_DIR, "desktop"))
     self.assertTrue(res)
     self.assertEqual(db.get_doccount(), 5)
     return db
コード例 #16
0
 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")