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


Python models.SuperSearch类代码示例

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


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

示例1: assert_supersearch_no_errors

def assert_supersearch_no_errors():
    """Make sure an uncached SuperSearch query doesn't have any errors"""
    supersearch = SuperSearch()
    # We don't want any caching this time
    supersearch.cache_seconds = 0
    results = supersearch.get(
        product=settings.DEFAULT_PRODUCT,
        _results_number=1,
        _columns=['uuid'],
        _facets_size=1,
    )
    assert not results['errors'], results['errors']
开发者ID:lonnen,项目名称:socorro,代码行数:12,代码来源:views.py

示例2: test_assert_supersearch_errors

    def test_assert_supersearch_errors(self):
        searches = []

        def mocked_supersearch_get(**params):
            searches.append(params)
            eq_(params['product'], [settings.DEFAULT_PRODUCT])
            eq_(params['_results_number'], 1)
            eq_(params['_columns'], ['uuid'])
            return {
                'hits': [
                    {'uuid': '12345'},
                ],
                'facets': [],
                'total': 320,
                'errors': ['bad'],
            }

        SuperSearch.implementation().get.side_effect = (
            mocked_supersearch_get
        )
        assert_raises(
            AssertionError,
            assert_supersearch_no_errors
        )
        assert len(searches) == 1
开发者ID:Krispy2009,项目名称:socorro,代码行数:25,代码来源:test_views.py

示例3: test_parameters

    def test_parameters(self):
        def mocked_supersearch_get(**params):
            # Verify that all expected parameters are in the URL.
            ok_("product" in params)
            ok_("WaterWolf" in params["product"])
            ok_("NightTrain" in params["product"])

            ok_("address" in params)
            ok_("0x0" in params["address"])
            ok_("0xa" in params["address"])

            ok_("reason" in params)
            ok_("^hello" in params["reason"])
            ok_("$thanks" in params["reason"])

            ok_("java_stack_trace" in params)
            ok_("Exception" in params["java_stack_trace"])

            return {"hits": [], "facets": "", "total": 0}

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        url = reverse("signature:signature_reports")

        response = self.client.get(
            url,
            {
                "signature": DUMB_SIGNATURE,
                "product": ["WaterWolf", "NightTrain"],
                "address": ["0x0", "0xa"],
                "reason": ["^hello", "$thanks"],
                "java_stack_trace": "Exception",
            },
        )
        eq_(response.status_code, 200)
开发者ID:snorp,项目名称:socorro,代码行数:35,代码来源:test_views.py

示例4: test_topcrasher_modes

    def test_topcrasher_modes(self, rpost):
        rpost.side_effect = mocked_post_123

        def mocked_supersearch_get(**params):
            return {"hits": [], "facets": {"signature": []}, "total": 0}

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        now = datetime.datetime.utcnow()
        today = now.replace(hour=0, minute=0, second=0, microsecond=0)

        timestr = "%Y-%m-%d %H:%M:%S"
        now = now.strftime(timestr)
        today = today.strftime(timestr)

        with freezegun.freeze_time(now, tz_offset=0):
            # By default, it returns "real-time" data.
            response = self.client.get(self.base_url, {"product": "WaterWolf", "version": "19.0"})
            eq_(response.status_code, 200)
            ok_(now in response.content, now)
            ok_(today not in response.content)

            # Now test the "day time" data.
            response = self.client.get(
                self.base_url, {"product": "WaterWolf", "version": "19.0", "_tcbs_mode": "byday"}
            )
            eq_(response.status_code, 200)
            ok_(today in response.content)
            ok_(now not in response.content)
开发者ID:pcabido,项目名称:socorro,代码行数:29,代码来源:test_views.py

示例5: test_healthcheck

    def test_healthcheck(self, mocked_elasticsearch, rget):
        searches = []

        def mocked_supersearch_get(**params):
            searches.append(params)
            eq_(params['product'], [settings.DEFAULT_PRODUCT])
            eq_(params['_results_number'], 1)
            eq_(params['_columns'], ['uuid'])
            return {
                'hits': [
                    {'uuid': '12345'},
                ],
                'facets': [],
                'total': 30002,
                'errors': [],
            }

        SuperSearch.implementation().get.side_effect = (
            mocked_supersearch_get
        )

        def mocked_requests_get(url, **params):
            return Response(True)

        rget.side_effect = mocked_requests_get

        url = reverse('monitoring:healthcheck')
        response = self.client.get(url)
        eq_(response.status_code, 200)
        eq_(json.loads(response.content)['ok'], True)

        assert len(searches) == 1
开发者ID:Krispy2009,项目名称:socorro,代码行数:32,代码来源:test_views.py

示例6: supersearch_field_update

def supersearch_field_update(request):
    field_data = _get_supersearch_field_data(request.POST)

    if isinstance(field_data, basestring):
        return http.HttpResponseBadRequest(field_data)

    api = SuperSearchField()
    api.update_field(**field_data)

    SuperSearch.clear_implementations_cache()

    log(request.user, 'supersearch_field.put', field_data)

    # Refresh the cache for the fields service.
    SuperSearchFields().get(refresh_cache=True)

    return redirect(reverse('manage:supersearch_fields'))
开发者ID:lonnen,项目名称:socorro,代码行数:17,代码来源:views.py

示例7: supersearch_field_delete

def supersearch_field_delete(request):
    field_name = request.GET.get('name')

    if not field_name:
        return http.HttpResponseBadRequest('A "name" is needed')

    api = SuperSearchField()
    api.delete_field(name=field_name)

    SuperSearch.clear_implementations_cache()

    log(request.user, 'supersearch_field.delete', {'name': field_name})

    # Refresh the cache for the fields service.
    SuperSearchFields().get(refresh_cache=True)

    url = reverse('manage:supersearch_fields')
    return redirect(url)
开发者ID:lonnen,项目名称:socorro,代码行数:18,代码来源:views.py

示例8: test_signature_reports_pagination

    def test_signature_reports_pagination(self):
        """Test that the pagination of results works as expected.
        """

        def mocked_supersearch_get(**params):
            assert '_columns' in params

            # Make sure a negative page does not lead to negative offset value.
            # But instead it is considered as the page 1 and thus is not added.
            eq_(params.get('_results_offset'), 0)

            hits = []
            for i in range(140):
                hits.append({
                    "signature": "nsASDOMWindowEnumerator::GetNext()",
                    "date": "2017-01-31T23:12:57",
                    "uuid": i,
                    "product": "WaterWolf",
                    "version": "1.0",
                    "platform": "Linux",
                    "build_id": 888981
                })
            return {
                "hits": self.only_certain_columns(hits, params['_columns']),
                "facets": "",
                "total": len(hits)
            }

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        url = reverse('signature:signature_reports')

        response = self.client.get(
            url,
            {
                'signature': DUMB_SIGNATURE,
                'product': ['WaterWolf'],
                '_columns': ['platform']
            }
        )

        eq_(response.status_code, 200)
        ok_('140' in response.content)

        # Check that the pagination URL contains all three expected parameters.
        doc = pyquery.PyQuery(response.content)
        next_page_url = str(doc('.pagination a').eq(0))
        ok_('product=WaterWolf' in next_page_url)
        ok_('_columns=platform' in next_page_url)
        ok_('page=2' in next_page_url)

        # Test that a negative page value does not break it.
        response = self.client.get(url, {
            'signature': DUMB_SIGNATURE,
            'page': '-1',
        })
        eq_(response.status_code, 200)
开发者ID:mmohrhard,项目名称:socorro,代码行数:57,代码来源:test_views.py

示例9: test_signature_graphs

    def test_signature_graphs(self):
        def mocked_supersearch_get(**params):
            ok_("signature" in params)
            eq_(params["signature"], ["=" + DUMB_SIGNATURE])

            ok_("_histogram.date" in params)
            ok_("_facets" in params)

            if "product" in params["_facets"]:
                return {
                    "hits": [],
                    "total": 4,
                    "facets": {
                        "product": [{"count": 4, "term": "WaterWolf"}],
                        "histogram_date": [
                            {
                                "count": 2,
                                "term": "2015-08-05T00:00:00+00:00",
                                "facets": {"product": [{"count": 2, "term": "WaterWolf"}]},
                            },
                            {
                                "count": 2,
                                "term": "2015-08-06T00:00:00+00:00",
                                "facets": {"product": [{"count": 2, "term": "WaterWolf"}]},
                            },
                        ],
                    },
                }

            return {"hits": [], "total": 0, "facets": {"platform": [], "signature": [], "histogram_date": []}}

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        # Test with no results
        url = reverse("signature:signature_graphs", args=("platform",))

        response = self.client.get(url, {"signature": DUMB_SIGNATURE})
        eq_(response.status_code, 200)
        ok_("application/json" in response["content-type"])
        struct = json.loads(response.content)
        ok_("aggregates" in struct)
        eq_(len(struct["aggregates"]), 0)
        ok_("term_counts" in struct)
        eq_(len(struct["term_counts"]), 0)

        # Test with results
        url = reverse("signature:signature_graphs", args=("product",))

        response = self.client.get(url, {"signature": DUMB_SIGNATURE})
        eq_(response.status_code, 200)
        ok_("application/json" in response["content-type"])
        struct = json.loads(response.content)
        ok_("aggregates" in struct)
        eq_(len(struct["aggregates"]), 2)
        ok_("term_counts" in struct)
        eq_(len(struct["term_counts"]), 1)
开发者ID:snorp,项目名称:socorro,代码行数:56,代码来源:test_views.py

示例10: test_signature_comments_pagination

    def test_signature_comments_pagination(self):
        """Test that the pagination of comments works as expected. """

        def mocked_supersearch_get(**params):
            assert '_columns' in params

            if params.get('_results_offset') != 0:
                hits_range = range(100, 140)
            else:
                hits_range = range(100)

            hits = []
            for i in hits_range:
                hits.append({
                    "date": "2017-01-31T23:12:57",
                    "uuid": i,
                    "user_comments": "hi",
                })

            return {
                "hits": self.only_certain_columns(hits, params['_columns']),
                "total": 140
            }

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        url = reverse('signature:signature_comments')

        response = self.client.get(
            url,
            {
                'signature': DUMB_SIGNATURE,
                'product': ['WaterWolf'],
            }
        )

        eq_(response.status_code, 200)
        ok_('140' in response.content)
        ok_('99' in response.content)
        ok_('139' not in response.content)

        # Check that the pagination URL contains all expected parameters.
        doc = pyquery.PyQuery(response.content)
        next_page_url = str(doc('.pagination a').eq(0))
        ok_('product=WaterWolf' in next_page_url)
        ok_('page=2' in next_page_url)

        response = self.client.get(url, {
            'signature': DUMB_SIGNATURE,
            'page': '2',
        })
        eq_(response.status_code, 200)
        ok_('140' in response.content)
        ok_('99' not in response.content)
        ok_('139' in response.content)
开发者ID:mmohrhard,项目名称:socorro,代码行数:55,代码来源:test_views.py

示例11: supersearch_field_create

def supersearch_field_create(request):
    field_data = _get_supersearch_field_data(request.POST)

    if isinstance(field_data, basestring):
        return http.HttpResponseBadRequest(field_data)

    api = SuperSearchField()
    api.create_field(**field_data)

    log(request.user, 'supersearch_field.post', field_data)

    # Refresh the cache for the fields service.
    SuperSearchFields().get(refresh_cache=True)
    SuperSearch.clear_implementations_cache()

    # The API is using cache to get all fields by a specific namespace
    # for the whitelist lookup, clear that cache too.
    cache.delete('api_supersearch_fields_%s' % field_data['namespace'])

    return redirect(reverse('manage:supersearch_fields'))
开发者ID:lonnen,项目名称:socorro,代码行数:20,代码来源:views.py

示例12: test_search_custom

    def test_search_custom(self):

        def mocked_supersearch_get(**params):
            return None

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        self.create_custom_query_perm()

        url = reverse('supersearch.search_custom')
        response = self.client.get(url)
        eq_(response.status_code, 200)
        ok_('Run a search to get some results' in response.content)
开发者ID:snorp,项目名称:socorro,代码行数:13,代码来源:test_views.py

示例13: test_search_results_parameters

    def test_search_results_parameters(self, rpost):
        def mocked_post(**options):
            assert 'bugs' in options['url'], options['url']
            return Response({
                "hits": [],
                "total": 0
            })

        rpost.side_effect = mocked_post

        def mocked_supersearch_get(**params):
            # Verify that all expected parameters are in the URL.
            ok_('product' in params)
            ok_('WaterWolf' in params['product'])
            ok_('NightTrain' in params['product'])

            ok_('address' in params)
            ok_('0x0' in params['address'])
            ok_('0xa' in params['address'])

            ok_('reason' in params)
            ok_('^hello' in params['reason'])
            ok_('$thanks' in params['reason'])

            ok_('java_stack_trace' in params)
            ok_('Exception' in params['java_stack_trace'])

            return {
                "hits": [],
                "facets": "",
                "total": 0
            }

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        url = reverse('supersearch.search_results')

        response = self.client.get(
            url, {
                'product': ['WaterWolf', 'NightTrain'],
                'address': ['0x0', '0xa'],
                'reason': ['^hello', '$thanks'],
                'java_stack_trace': 'Exception',
            }
        )
        eq_(response.status_code, 200)
开发者ID:snorp,项目名称:socorro,代码行数:46,代码来源:test_views.py

示例14: test_topcrasher_without_any_signatures

    def test_topcrasher_without_any_signatures(self, rget, rpost):
        url = self.base_url + '?product=WaterWolf&version=19.0'
        response = self.client.get(self.base_url, {
            'product': 'WaterWolf',
        })
        ok_(url in response['Location'])

        rpost.side_effect = mocked_post_123

        def mocked_get(url, params, **options):
            if '/products' in url:
                return Response("""
                {
                  "hits": [
                    {
                        "is_featured": true,
                        "throttle": 1.0,
                        "end_date": "string",
                        "start_date": "integer",
                        "build_type": "string",
                        "product": "WaterWolf",
                        "version": "19.0",
                        "has_builds": true
                    }],
                    "total": "1"
                }
                """)
            raise NotImplementedError(url)
        rget.side_effect = mocked_get

        def mocked_supersearch_get(**params):
            return {
                'hits': [],
                'facets': {
                    'signature': []
                },
                'total': 0
            }
        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        response = self.client.get(self.base_url, {
            'product': 'WaterWolf',
            'version': '19.0',
        })
        eq_(response.status_code, 200)
开发者ID:snorp,项目名称:socorro,代码行数:45,代码来源:test_views.py

示例15: test_signature_aggregation

    def test_signature_aggregation(self):
        def mocked_supersearch_get(**params):
            ok_("signature" in params)
            eq_(params["signature"], ["=" + DUMB_SIGNATURE])

            ok_("_facets" in params)

            if "product" in params["_facets"]:
                return {
                    "hits": [],
                    "facets": {
                        "product": [
                            {"term": "windows", "count": 42},
                            {"term": "linux", "count": 1337},
                            {"term": "mac", "count": 3},
                        ]
                    },
                    "total": 1382,
                }

            # the default
            return {"hits": [], "facets": {"platform": []}, "total": 0}

        SuperSearch.implementation().get.side_effect = mocked_supersearch_get

        # Test with no results.
        url = reverse("signature:signature_aggregation", args=("platform",))

        response = self.client.get(url, {"signature": DUMB_SIGNATURE})
        eq_(response.status_code, 200)
        ok_("Product" not in response.content)
        ok_("No results were found" in response.content)

        # Test with results.
        url = reverse("signature:signature_aggregation", args=("product",))

        response = self.client.get(url, {"signature": DUMB_SIGNATURE})
        eq_(response.status_code, 200)
        ok_("Product" in response.content)
        ok_("1337" in response.content)
        ok_("linux" in response.content)
        ok_(str(1337 / 1382 * 100) in response.content)
        ok_("windows" in response.content)
        ok_("mac" in response.content)
开发者ID:snorp,项目名称:socorro,代码行数:44,代码来源:test_views.py


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