def test_reinstall_purchased_xapian(self, mock_helper, mock_agent): small_available = [ self.available[0] ] mock_agent.return_value = self._make_fake_scagent( small_available, self.available_for_me) db = xapian.inmemory_open() cache = get_test_pkg_info() # now create purchased debs xapian index (in memory because # we store the repository passwords in here) old_db_len = db.get_doccount() update_from_software_center_agent(db, cache) # ensure we have the new item self.assertEqual(db.get_doccount(), old_db_len+2) # query query = get_reinstall_previous_purchases_query() enquire = xapian.Enquire(db) enquire.set_query(query) matches = enquire.get_mset(0, db.get_doccount()) self.assertEqual(len(matches), 1) distroseries = platform.dist()[2] for m in matches: doc = db.get_document(m.docid) self.assertEqual(doc.get_value(XapianValues.PKGNAME), "photobomb") self.assertEqual( doc.get_value(XapianValues.ARCHIVE_SIGNING_KEY_ID), "1024R/75254D99") self.assertEqual(doc.get_value(XapianValues.ARCHIVE_DEB_LINE), "deb https://username:random3atoken@" "private-ppa.launchpad.net/commercial-ppa-uploaders" "/photobomb/ubuntu %s main" % distroseries)
def test_build_from_software_center_agent(self, mock_find_oauth): # pretend we have no token mock_find_oauth.return_value = None db = xapian.inmemory_open() cache = apt.Cache() # monkey patch distro to ensure we get data distro = softwarecenter.distro.get_distro() distro.get_codename = lambda: "natty" # we test against the real https://software-center.ubuntu.com here # so we need network res = update_from_software_center_agent(db, cache, ignore_cache=True) # check results self.assertTrue(res) self.assertTrue(db.get_doccount() > 1) for p in db.postlist(""): doc = db.get_document(p.docid) ppa = doc.get_value(XapianValues.ARCHIVE_PPA) self.assertTrue( ppa.startswith("commercial-ppa") and ppa.count("/") == 1, "ARCHIVE_PPA value incorrect, got '%s'" % ppa) self.assertTrue("-icon-" in doc.get_value(XapianValues.ICON)) # check support url in the DB url = doc.get_value(XapianValues.SUPPORT_SITE_URL) if url: self.assertTrue( url.startswith("http") or url.startswith("mailto:"))
def test_build_from_software_center_agent(self): from softwarecenter.db.update import update_from_software_center_agent db = xapian.WritableDatabase("./data/test.db", xapian.DB_CREATE_OR_OVERWRITE) cache = apt.Cache() # monkey patch distro to ensure we get data import softwarecenter.distro distro = softwarecenter.distro.get_distro() distro.get_codename = lambda: "natty" # we test against the real https://software-center.ubuntu.com here # so we need network softwarecenter.paths.datadir="../data" os.environ["PYTHONPATH"] = ".." res = update_from_software_center_agent(db, cache, ignore_cache=True) # check results self.assertTrue(res) self.assertTrue(db.get_doccount() > 1) for p in db.postlist(""): doc = db.get_document(p.docid) ppa = doc.get_value(XapianValues.ARCHIVE_PPA) self.assertTrue(ppa.startswith("commercial-ppa") and ppa.count("/") == 1, "ARCHIVE_PPA value incorrect, got '%s'" % ppa) self.assertTrue( doc.get_value(XapianValues.ICON).startswith("sc-agent"))
def test_build_from_software_center_agent(self): db = xapian.WritableDatabase("./data/test.db", xapian.DB_CREATE_OR_OVERWRITE) cache = apt.Cache() # monkey patch distro to ensure we get data import softwarecenter.distro distro = softwarecenter.distro.get_distro() distro.get_codename = lambda: "natty" # we test against the real https://software-center.ubuntu.com here # so we need network res = update_from_software_center_agent(db, cache, ignore_cache=True) # check results self.assertTrue(res) self.assertTrue(db.get_doccount() > 1) for p in db.postlist(""): doc = db.get_document(p.docid) ppa = doc.get_value(XapianValues.ARCHIVE_PPA) self.assertTrue( ppa.startswith("commercial-ppa") and ppa.count("/") == 1, "ARCHIVE_PPA value incorrect, got '%s'" % ppa ) self.assertTrue("-icon-" in doc.get_value(XapianValues.ICON)) # check support url in the DB url = doc.get_value(XapianValues.SUPPORT_SITE_URL) if url: self.assertTrue(url.startswith("http") or url.startswith("mailto:"))
def test_build_from_software_center_agent(self, mock_find_oauth): # pretend we have no token mock_find_oauth.return_value = None db = xapian.inmemory_open() cache = apt.Cache() # monkey patch distro to ensure we get data distro = softwarecenter.distro.get_distro() distro.get_codename = lambda: "natty" # we test against the real https://software-center.ubuntu.com here # so we need network res = update_from_software_center_agent(db, cache, ignore_cache=True) # check results self.assertTrue(res) self.assertTrue(db.get_doccount() > 1) for p in db.postlist(""): doc = db.get_document(p.docid) ppa = doc.get_value(XapianValues.ARCHIVE_PPA) self.assertTrue( ppa.startswith("commercial-ppa") and ppa.count("/") == 1, "ARCHIVE_PPA value incorrect, got '%s'" % ppa ) self.assertTrue("-icon-" in doc.get_value(XapianValues.ICON)) # check support url in the DB url = doc.get_value(XapianValues.SUPPORT_SITE_URL) if url: self.assertTrue(url.startswith("http") or url.startswith("mailto:"))
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"]
def test_build_from_software_center_agent(self): db = xapian.WritableDatabase("./data/test.db", xapian.DB_CREATE_OR_OVERWRITE) cache = apt.Cache() # monkey patch distro to ensure we get data import softwarecenter.distro distro = softwarecenter.distro.get_distro() distro.get_codename = lambda: "natty" # we test against the real https://software-center.ubuntu.com here # so we need network res = update_from_software_center_agent(db, cache, ignore_cache=True) # check results self.assertTrue(res) self.assertTrue(db.get_doccount() > 1) for p in db.postlist(""): doc = db.get_document(p.docid) ppa = doc.get_value(XapianValues.ARCHIVE_PPA) self.assertTrue( ppa.startswith("commercial-ppa") and ppa.count("/") == 1, "ARCHIVE_PPA value incorrect, got '%s'" % ppa) self.assertTrue("-icon-" in doc.get_value(XapianValues.ICON)) # check support url in the DB url = doc.get_value(XapianValues.SUPPORT_SITE_URL) if url: self.assertTrue( url.startswith("http") or url.startswith("mailto:"))
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(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)
def test_for_purchase_apps_date_published(self, mock_find_oauth): # pretend we have no token mock_find_oauth.return_value = None #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.inmemory_open() 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 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 test_for_purchase_apps_date_published(self, mock_find_oauth): # pretend we have no token mock_find_oauth.return_value = None # 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.inmemory_open() 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 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)