Exemplo n.º 1
0
 def __init__(self, sca_subscription):
     # The sca_subscription is a PistonResponseObject, whereas any child
     # objects are normal Python dicts.
     self.sca_subscription = sca_subscription
     self.MAPPING.update(self.SUBSCRIPTION_MAPPING)
     super(SCAPurchasedApplicationParser, self).__init__(
         PistonResponseObject.from_dict(sca_subscription.application))
Exemplo n.º 2
0
    def test_desktop_categories_no_department(self):
        piston_app = PistonResponseObject.from_dict(
            json.loads(AVAILABLE_APPS_JSON)[0])
        del (piston_app.department)
        parser = self._make_application_parser(piston_app)

        self.assertEqual(["AudioVideo"], parser.get_desktop_categories())
Exemplo n.º 3
0
 def __init__(self, sca_subscription):
     # The sca_subscription is a PistonResponseObject, whereas any child
     # objects are normal Python dicts.
     self.sca_subscription = sca_subscription
     self.MAPPING.update(self.SUBSCRIPTION_MAPPING)
     super(SCAPurchasedApplicationParser, self).__init__(
         PistonResponseObject.from_dict(sca_subscription.application))
Exemplo n.º 4
0
    def test_desktop_categories_no_department(self):
        piston_app = PistonResponseObject.from_dict(
            json.loads(AVAILABLE_APPS_JSON)[0])
        del(piston_app.department)
        parser = self._make_application_parser(piston_app)

        self.assertEqual(["AudioVideo"], parser.get_desktop_categories())
 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)
Exemplo n.º 7
0
    def test_license_key_present(self):
        piston_subscription = PistonResponseObject.from_dict(
            json.loads(SUBSCRIPTIONS_FOR_ME_JSON)[0])
        piston_subscription.license_key = 'abcd'
        piston_subscription.license_key_path = '/foo'
        parser = self._make_application_parser(piston_subscription)

        self.assertEqual('abcd', parser.get_value(AppInfoFields.LICENSE_KEY))
        self.assertEqual(
            '/foo', parser.get_value(AppInfoFields.LICENSE_KEY_PATH))
 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)
Exemplo n.º 9
0
    def test_license_key_present(self):
        piston_subscription = PistonResponseObject.from_dict(
            json.loads(SUBSCRIPTIONS_FOR_ME_JSON)[0])
        piston_subscription.license_key = 'abcd'
        piston_subscription.license_key_path = '/foo'
        parser = self._make_application_parser(piston_subscription)

        self.assertTrue(parser.has_option_desktop('License-Key'))
        self.assertTrue(parser.has_option_desktop('License-Key-Path'))
        self.assertEqual('abcd', parser.get_desktop('License-Key'))
        self.assertEqual('/foo', parser.get_desktop('License-Key-Path'))
Exemplo n.º 10
0
    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_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)
Exemplo n.º 12
0
    def test_license_key_present(self):
        piston_subscription = PistonResponseObject.from_dict(
            json.loads(SUBSCRIPTIONS_FOR_ME_JSON)[0])
        piston_subscription.license_key = 'abcd'
        piston_subscription.license_key_path = '/foo'
        parser = self._make_application_parser(piston_subscription)

        self.assertTrue(parser.has_option_desktop('License-Key'))
        self.assertTrue(parser.has_option_desktop('License-Key-Path'))
        self.assertEqual('abcd', parser.get_desktop('License-Key'))
        self.assertEqual('/foo', parser.get_desktop('License-Key-Path'))
 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 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_whiteandblack_blacklists(self, get_region_cached_mock):
     """Ignore regions that are in both black and whitelists."""
     get_region_cached_mock.return_value = {
         "countrycode": "de",
     }
     app_dict = make_software_center_agent_app_dict({
         "debtags": [
             "%s%s" % (REGION_WHITELIST_TAG, "DE"),
             "%s%s" % (REGION_BLACKLIST_TAG, "DE"),
             "%s%s" % (REGION_BLACKLIST_TAG, "US"),
             "%s%s" % (REGION_WHITELIST_TAG, "ES")
         ]
     })
     # 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)
Exemplo n.º 17
0
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 = softwarecenter.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 = parser.make_doc(db._aptcache)
    app_details = AppDetails(db, doc)
    return app_details
Exemplo n.º 19
0
 def _make_available_for_me_list(self):
     my_subscriptions = json.loads(SUBSCRIPTIONS_FOR_ME_JSON)
     return list(
         PistonResponseObject.from_dict(subs) for subs in my_subscriptions)
Exemplo n.º 20
0
    def _make_application_parser(self, piston_subscription=None):
        if piston_subscription is None:
            piston_subscription = PistonResponseObject.from_dict(
                json.loads(SUBSCRIPTIONS_FOR_ME_JSON)[0])

        return SCAPurchasedApplicationParser(piston_subscription)
Exemplo n.º 21
0
 def _make_available_for_me_list(self):
     my_subscriptions = json.loads(SUBSCRIPTIONS_FOR_ME_JSON)
     return list(
         PistonResponseObject.from_dict(subs) for subs in my_subscriptions)
Exemplo n.º 22
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)
Exemplo n.º 23
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)
Exemplo n.º 24
0
 def _make_available_list(self):
     available_apps = json.loads(AVAILABLE_APPS_JSON)
     return list(
         PistonResponseObject.from_dict(subs) for subs in available_apps)
Exemplo n.º 25
0
    def _make_application_parser(self, piston_subscription=None):
        if piston_subscription is None:
            piston_subscription = PistonResponseObject.from_dict(
                json.loads(SUBSCRIPTIONS_FOR_ME_JSON)[0])

        return SCAPurchasedApplicationParser(piston_subscription)
 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
Exemplo n.º 27
0
 def _get_app_details_from_app_dict(self, app_dict):
     item = PistonResponseObject.from_dict(app_dict)
     parser = SCAApplicationParser(item)
     doc = make_doc_from_parser(parser, self.db._aptcache)
     app_details = AppDetails(self.db, doc)
     return app_details