def autocompeter_test(request):
    domain = getattr(
        settings,
        'AUTOCOMPETER_DOMAIN',
        RequestSite(request).domain
    )
    return test(request.GET['term'], domain=domain)
Exemple #2
0
def autocompeter_test(request):
    domain = getattr(
        settings,
        'AUTOCOMPETER_DOMAIN',
        RequestSite(request).domain
    )
    return test(request.GET['term'], domain=domain)
    def test_test(self, rget):
        def mocked_get(url, **options):
            return Response({
                'terms': ['foo'],
                'results': [
                    ['/url', 'Page'],
                ]
            },
                            200,
                            headers={'content-type': 'application/json'})

        rget.side_effect = mocked_get

        result = autocompeter.test('foo')
        eq_(result['terms'], ['foo'])
        eq_(result['results'], [['/url', 'Page']])
    def test_test(self, rget):

        def mocked_get(url, **options):
            return Response(
                {
                    'terms': ['foo'],
                    'results': [
                        ['/url', 'Page'],
                    ]
                },
                200,
                headers={
                    'content-type': 'application/json'
                }
            )

        rget.side_effect = mocked_get

        result = autocompeter.test('foo')
        eq_(result['terms'], ['foo'])
        eq_(result['results'], [['/url', 'Page']])