def test_region_blacklist_blacklists(self, get_region_cached_mock):
     """Test that the region blacklist adds non-blacklisted locations"""
     get_region_cached_mock.return_value = {"countrycode": "de"}
     app_dict = make_software_center_agent_app_dict({"debtags": ["%s%s" % (REGION_BLACKLIST_TAG, "ES")]})
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     self.assertNotEqual(doc, None)
 def test_no_region_tags_passes(self, get_region_cached_mock):
     """Do not skip apps with no white or blacklist tags."""
     get_region_cached_mock.return_value = {"countrycode": "es"}
     app_dict = make_software_center_agent_app_dict({"debtags": []})
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     self.assertNotEqual(doc, None)
 def test_no_region_tags_passes(self, get_region_cached_mock):
     """Do not skip apps with no white or blacklist tags."""
     get_region_cached_mock.return_value = {
         "countrycode": "es",
     }
     app_dict = make_software_center_agent_app_dict({"debtags": []})
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     self.assertNotEqual(doc, None)
 def test_region_blacklist_blacklists(self, get_region_cached_mock):
     """Test that the region blacklist adds non-blacklisted locations"""
     get_region_cached_mock.return_value = {
         "countrycode": "de",
     }
     app_dict = make_software_center_agent_app_dict(
         {"debtags": ["%s%s" % (REGION_BLACKLIST_TAG, "ES")]})
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     self.assertNotEqual(doc, None)
 def test_region_whitelist_blacklists(self, get_region_cached_mock):
     """Test that the whitelist ignores non-whitelist locations"""
     get_region_cached_mock.return_value = {
         "countrycode": "de",
     }
     app_dict = make_software_center_agent_app_dict({
         "debtags": [
             "%s%s" % (REGION_WHITELIST_TAG, "ES"),
             "%s%s" % (REGION_BLACKLIST_TAG, "CA"),
             "%s%s" % (REGION_WHITELIST_TAG, "US")
         ]
     })
     # see _get_app_details_from_app_dict
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(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"""
     get_region_cached_mock.return_value = {"countrycode": "de"}
     app_dict = make_software_center_agent_app_dict(
         {
             "debtags": [
                 "%s%s" % (REGION_WHITELIST_TAG, "ES"),
                 "%s%s" % (REGION_BLACKLIST_TAG, "CA"),
                 "%s%s" % (REGION_WHITELIST_TAG, "US"),
             ]
         }
     )
     # see _get_app_details_from_app_dict
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     self.assertEqual(doc, None)
 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_whitelists(self, get_region_cached_mock):
     """Test that the whitelist adds whitelisted locations"""
     from softwarecenter.region import REGION_WHITELIST_TAG
     get_region_cached_mock.return_value = {
         "countrycode": "es",
     }
     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.assertNotEqual(doc, None)
Example #9
0
 def _make_application_parser(self, piston_application=None):
     if piston_application is None:
         piston_application = PistonResponseObject.from_dict(
             json.loads(AVAILABLE_APPS_JSON)[0])
     return SCAApplicationParser(piston_application)
 def _get_app_details_from_app_dict(self, app_dict):
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     app_details = AppDetails(self.db, doc)
     return app_details
 def _get_app_details_from_app_dict(self, app_dict):
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = parser.make_doc(self.db._aptcache)
     app_details = AppDetails(self.db, doc)
     return app_details