def test_channel_detection_extras(self, mock): # we need to patch os.path.exists as "AppDetails.channelname" will # check if there is a matching channel description file on disk os.path.exists.return_value = True # setup dict app_dict = make_software_center_agent_app_dict() app_dict["archive_root"] = "http://extras.ubuntu.com/" app_details = self._get_app_details_from_app_dict(app_dict) # ensure that archive.canonical.com archive roots are detected # as the partner channel self.assertEqual(app_details.channelname, "ubuntu-extras")
def test_region_blacklist(self, get_region_cached_mock): from softwarecenter.region import REGION_BLACKLIST_TAG get_region_cached_mock.return_value = {"countrycode": "es"} app_dict = make_software_center_agent_app_dict() app_dict["debtags"] = ["%s%s" % (REGION_BLACKLIST_TAG, "es")] # see _get_app_details_from_app_dict item = PistonResponseObject.from_dict(app_dict) parser = SCAApplicationParser(item) doc = make_doc_from_parser(parser, self.db._aptcache) self.assertEqual(doc, None)
def test_date_no_published(self): app_dict = make_software_center_agent_app_dict() app_dict["date_published"] = "None" app_details = self._get_app_details_from_app_dict(app_dict) # ensure that archive.canonical.com archive roots are detected # as the partner channel self.assertEqual(app_details.date_published, "") # and again app_dict["date_published"] = "2012-01-21 02:15:10.358926" app_details = self._get_app_details_from_app_dict(app_dict) # ensure that archive.canonical.com archive roots are detected # as the partner channel self.assertEqual(app_details.date_published, "2012-01-21 02:15:10")
def test_region_blacklist(self, get_region_cached_mock): from softwarecenter.region import REGION_BLACKLIST_TAG get_region_cached_mock.return_value = { "countrycode": "es", } app_dict = make_software_center_agent_app_dict() app_dict["debtags"] = [ "%s%s" % (REGION_BLACKLIST_TAG, "es"), ] # see _get_app_details_from_app_dict item = PistonResponseObject.from_dict(app_dict) parser = SCAApplicationParser(item) doc = make_doc_from_parser(parser, self.db._aptcache) self.assertEqual(doc, None)
def test_region_whitelist_blacklists(self, get_region_cached_mock): """Test that the whitelist ignores non-whitelist locations""" from softwarecenter.region import REGION_WHITELIST_TAG get_region_cached_mock.return_value = { "countrycode": "de", } app_dict = make_software_center_agent_app_dict() app_dict["debtags"] = [ "%s%s" % (REGION_WHITELIST_TAG, "ES"), ] # see _get_app_details_from_app_dict item = PistonResponseObject.from_dict(app_dict) parser = SCAApplicationParser(item) doc = make_doc_from_parser(parser, self.db._aptcache) self.assertEqual(doc, None)
def make_purchased_app_details(db=None, supported_series=None): """Return an AppDetail instance with the required attributes.""" app = make_software_center_agent_app_dict() subscription = make_software_center_agent_subscription_dict(app) if supported_series != None: subscription["application"]["series"] = supported_series else: # If no supportod_series kwarg was provided, we ensure the # current series/arch is supported. distro = get_distro() subscription["application"]["series"] = {distro.get_codename(): [distro.get_architecture()]} item = PistonResponseObject.from_dict(subscription) parser = SCAPurchasedApplicationParser(item) if db is None: db = get_test_db() doc = make_doc_from_parser(parser, db._aptcache) app_details = AppDetails(db, doc) return app_details
def make_purchased_app_details(db=None, supported_series=None): """Return an AppDetail instance with the required attributes.""" app = make_software_center_agent_app_dict() subscription = make_software_center_agent_subscription_dict(app) if supported_series != None: subscription['application']['series'] = supported_series else: # If no supportod_series kwarg was provided, we ensure the # current series/arch is supported. distro = get_distro() subscription['application']['series'] = { distro.get_codename(): [distro.get_architecture()] } item = PistonResponseObject.from_dict(subscription) parser = SCAPurchasedApplicationParser(item) if db is None: db = get_test_db() doc = make_doc_from_parser(parser, db._aptcache) app_details = AppDetails(db, doc) return app_details