当前位置: 首页>>代码示例>>Python>>正文


Python models.Addon类代码示例

本文整理汇总了Python中addons.models.Addon的典型用法代码示例。如果您正苦于以下问题:Python Addon类的具体用法?Python Addon怎么用?Python Addon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Addon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_filter_or

    def test_filter_or(self):
        qs = Addon.search().filter(type=1).filter(or_=dict(status=1, app=2))
        filters = qs._build_query()['query']['filtered']['filter']
        # Filters:
        # {'and': [
        #     {'term': {'type': 1}},
        #     {'or': [{'term': {'status': 1}}, {'term': {'app': 2}}]},
        # ]}
        eq_(filters.keys(), ['and'])
        ok_({'term': {'type': 1}} in filters['and'])
        or_clause = sorted(filters['and'])[0]
        eq_(or_clause.keys(), ['or'])
        ok_({'term': {'status': 1}} in or_clause['or'])
        ok_({'term': {'app': 2}} in or_clause['or'])

        qs = Addon.search().filter(type=1, or_=dict(status=1, app=2))
        filters = qs._build_query()['query']['filtered']['filter']
        # Filters:
        # {'and': [
        #     {'term': {'type': 1}},
        #     {'or': [{'term': {'status': 1}}, {'term': {'app': 2}}]},
        # ]}
        eq_(filters.keys(), ['and'])
        ok_({'term': {'type': 1}} in filters['and'])
        or_clause = sorted(filters['and'])[0]
        eq_(or_clause.keys(), ['or'])
        ok_({'term': {'status': 1}} in or_clause['or'])
        ok_({'term': {'app': 2}} in or_clause['or'])
开发者ID:abdellah-bn,项目名称:olympia,代码行数:28,代码来源:test_search.py

示例2: setUp

 def setUp(self):
     super(TestModelBase, self).setUp()
     self.saved_cb = amo.models._on_change_callbacks.copy()
     amo.models._on_change_callbacks.clear()
     self.cb = Mock()
     self.cb.__name__ = 'testing_mock_callback'
     Addon.on_change(self.cb)
开发者ID:peterkinalex,项目名称:olympia,代码行数:7,代码来源:test_models.py

示例3: test_multiple_ignored

 def test_multiple_ignored(self):
     cb = Mock()
     cb.__name__ = 'something'
     old = len(amo.models._on_change_callbacks[Addon])
     Addon.on_change(cb)
     eq_(len(amo.models._on_change_callbacks[Addon]), old + 1)
     Addon.on_change(cb)
     eq_(len(amo.models._on_change_callbacks[Addon]), old + 1)
开发者ID:peterkinalex,项目名称:olympia,代码行数:8,代码来源:test_models.py

示例4: test_extra_query

    def test_extra_query(self):
        qs = Addon.search().extra(query={'type': 1})
        eq_(qs._build_query(), {'fields': ['id'],
                                'query': {'term': {'type': 1}}})

        qs = Addon.search().filter(status=1).extra(query={'type': 1})
        eq_(qs._build_query(), {'fields': ['id'],
                                'query': {'term': {'type': 1}},
                                'filter': {'term': {'status': 1}}})
开发者ID:Sancus,项目名称:zamboni,代码行数:9,代码来源:test_search.py

示例5: test_extra_order_by

    def test_extra_order_by(self):
        qs = Addon.search().extra(order_by=['-rating'])
        eq_(qs._build_query(), {'fields': ['id'],
                                'sort': [{'rating': 'desc'}]})

        qs = Addon.search().order_by('-id').extra(order_by=['-rating'])
        eq_(qs._build_query(), {'fields': ['id'],
                                'sort': [{'id': 'desc'},
                                         {'rating': 'desc'}]})
开发者ID:Sancus,项目名称:zamboni,代码行数:9,代码来源:test_search.py

示例6: test_is_unreviewed

    def test_is_unreviewed(self):
        """Test if add-on is experimental or not"""
        # public add-on
        a = Addon.objects.get(pk=3615)
        assert not a.is_unreviewed(), 'public add-on: is_unreviewed=False'

        # experimental add-on
        a = Addon(status=amo.STATUS_SANDBOX)
        assert a.is_unreviewed(), 'sandboxed add-on: is_unreviewed=True'
开发者ID:mccammos,项目名称:zamboni,代码行数:9,代码来源:test_models.py

示例7: test_is_unreviewed

    def test_is_unreviewed(self):
        """Test if add-on is unreviewed or not"""
        # public add-on
        a = Addon.objects.get(pk=3615)
        assert not a.is_unreviewed(), 'public add-on: is_unreviewed=False'

        # unreviewed add-on
        a = Addon(status=amo.STATUS_UNREVIEWED)
        assert a.is_unreviewed(), 'sandboxed add-on: is_unreviewed=True'
开发者ID:rlr,项目名称:zamboni,代码行数:9,代码来源:test_models.py

示例8: test_show_beta_with_beta_version

    def test_show_beta_with_beta_version(self, beta_mock):
        beta_mock.return_value = object()
        # Fake current_beta_version to return something truthy.
        a = Addon(status=amo.STATUS_PUBLIC)
        assert a.show_beta

        # We have a beta version but status has to be public.
        a.status = amo.STATUS_UNREVIEWED
        assert not a.show_beta
开发者ID:LittleForker,项目名称:zamboni,代码行数:9,代码来源:test_models.py

示例9: test_extra_filter

    def test_extra_filter(self):
        qs = Addon.search().extra(filter={"category__in": [1, 2]})
        eq_(qs._build_query(), {"fields": ["id"], "filter": {"in": {"category": [1, 2]}}})

        qs = Addon.search().filter(type=1).extra(filter={"category__in": [1, 2]})
        eq_(
            qs._build_query(),
            {"fields": ["id"], "filter": {"and": [{"term": {"type": 1}}, {"in": {"category": [1, 2]}}]}},
        )
开发者ID:rtilder,项目名称:zamboni,代码行数:9,代码来源:test_search.py

示例10: test_extra_query

    def test_extra_query(self):
        qs = Addon.search().extra(query={'type': 1})
        eq_(qs._build_query()['query']['function_score']['query'],
            {'term': {'type': 1}})

        qs = Addon.search().filter(status=1).extra(query={'type': 1})
        filtered = qs._build_query()['query']['filtered']
        eq_(filtered['query']['function_score']['query'], {'term': {'type': 1}})
        eq_(filtered['filter'], [{'term': {'status': 1}}])
开发者ID:callahad,项目名称:olympia,代码行数:9,代码来源:test_search.py

示例11: test_extra_filter

    def test_extra_filter(self):
        qs = Addon.search().extra(filter={'category__in': [1, 2]})
        eq_(qs._build_query()['query']['filtered']['filter'],
            [{'in': {'category': [1, 2]}}])

        qs = (Addon.search().filter(type=1)
              .extra(filter={'category__in': [1, 2]}))
        eq_(qs._build_query()['query']['filtered']['filter'],
            {'and': [{'term': {'type': 1}}, {'in': {'category': [1, 2]}}, ]})
开发者ID:srachit,项目名称:olympia,代码行数:9,代码来源:test_search.py

示例12: test_extra_filter_or

    def test_extra_filter_or(self):
        qs = Addon.search().extra(filter={'or_': {'status': 1, 'app': 2}})
        eq_(qs._build_query()['query']['filtered']['filter'],
            [{'or': [{'term': {'status': 1}}, {'term': {'app': 2}}]}])

        qs = (Addon.search().filter(type=1)
              .extra(filter={'or_': {'status': 1, 'app': 2}}))
        eq_(qs._build_query()['query']['filtered']['filter'],
            {'and': [{'term': {'type': 1}},
                     {'or': [{'term': {'status': 1}}, {'term': {'app': 2}}]}]})
开发者ID:srachit,项目名称:olympia,代码行数:10,代码来源:test_search.py

示例13: test_default_locale

    def test_default_locale(self):
        # Make sure default_locale follows the active translation.
        addon = Addon.from_upload(self.get_upload('search.xml'),
                                  [self.platform])
        eq_(addon.default_locale, 'en-US')

        translation.activate('es-ES')
        addon = Addon.from_upload(self.get_upload('search.xml'),
                                  [self.platform])
        eq_(addon.default_locale, 'es-ES')
        translation.deactivate()
开发者ID:LittleForker,项目名称:zamboni,代码行数:11,代码来源:test_models.py

示例14: test_support_addon

    def test_support_addon(self):
        a = Addon(id=12)
        eq_(support_addon(a), "")

        # TODO(jbalogh): check the url when using reverse
        a.wants_contributions = a.paypal_id = True
        eq_(PyQuery(support_addon(a))("a").text(), "Support this add-on")

        a.suggested_amount = "12"
        doc = PyQuery(support_addon(a))
        eq_(doc(".contribute").text(), "Support this add-on: Contribute $12.00")
开发者ID:sgarrity,项目名称:zamboni,代码行数:11,代码来源:test_helpers.py

示例15: create_file

    def create_file(self, **kwargs):
        addon = Addon()
        addon.save()
        ver = Version(version='0.1')
        ver.addon = addon
        ver.save()

        f = File(**kwargs)
        f.version = ver
        f.save()

        return f
开发者ID:ujdhesa,项目名称:olympia,代码行数:12,代码来源:test_models.py


注:本文中的addons.models.Addon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。