Exemplo n.º 1
0
def results_view(request):
    query = request.GET.get('q', '')

    results = dotgov.search(query)

    context = {'q': query, 'results': results}

    response = TemplateResponse(request, 'search/results.html', context)
    return response.render()
Exemplo n.º 2
0
def results_view(request):
    query = request.GET.get('q', '')

    results = dotgov.search(query)

    context = {
        'q': query,
        'results': results
    }

    response = TemplateResponse(request, 'search/results.html', context)
    return response.render()
Exemplo n.º 3
0
 def test_search_query(self, mock_get):
     mock_get.return_value.ok = True
     search('query')
     mock_get.return_value.json.assert_called()
Exemplo n.º 4
0
 def test_search_sort_by_out_of_bounds(self):
     with self.assertRaises(ValueError):
         search('query', sort_by='alpha')
Exemplo n.º 5
0
    def test_search_offset_out_of_bounds(self):
        with self.assertRaises(ValueError):
            search('query', offset=-1)

        with self.assertRaises(ValueError):
            search('query', offset=1000)
Exemplo n.º 6
0
    def test_search_limit_out_of_bounds(self):
        with self.assertRaises(ValueError):
            search('query', limit=0)

        with self.assertRaises(ValueError):
            search('query', limit=51)
Exemplo n.º 7
0
 def test_search_query_bad_upstream_response(self, mock_get):
     mock_get.return_value.ok = False
     result = search('')
     self.assertEqual(result, {})
Exemplo n.º 8
0
 def test_search_sort_by_out_of_bounds(self):
     with self.assertRaises(ValueError):
         search('query', sort_by='alpha')
Exemplo n.º 9
0
    def test_search_offset_out_of_bounds(self):
        with self.assertRaises(ValueError):
            search('query', offset=-1)

        with self.assertRaises(ValueError):
            search('query', offset=1000)
Exemplo n.º 10
0
    def test_search_limit_out_of_bounds(self):
        with self.assertRaises(ValueError):
            search('query', limit=0)

        with self.assertRaises(ValueError):
            search('query', limit=51)
Exemplo n.º 11
0
 def test_search_query_bad_upstream_response(self, mock_get):
     mock_get.return_value.ok = False
     result = search('')
     self.assertEquals(result, {})
Exemplo n.º 12
0
 def test_search_query(self, mock_get):
     mock_get.return_value.ok = True
     search('query')
     mock_get.return_value.json.assert_called()