Exemplo n.º 1
0
 def _make_chain(self, url):
     request = RequestFactory().get(url)
     argstring = request.path.split('filter/', 1)[-1]
     crime = models.Schema.objects.get(slug='crime')
     context = {'schema': crime}
     chain = FilterChain(request=request, context=context, schema=crime)
     chain.update_from_request(argstring=argstring, filter_sf_dict={})
     return chain
Exemplo n.º 2
0
 def _make_filter(self, *url_args):
     crime = mock.Mock(spec=models.Schema)
     from ebpub.db.schemafilters import LocationFilter
     reverse_args = ('locations', ) + url_args
     url = filter_reverse('crime', [reverse_args])
     req = RequestFactory().get(url)
     context = {'schema': crime}
     filt = LocationFilter(req, context, None, *reverse_args[1:])
     return filt
Exemplo n.º 3
0
 def _make_filter(self, *url_args):
     crime = mock.Mock()
     from ebpub.db.schemafilters import DateFilter
     url = filter_reverse('crime', [url_args])
     req = RequestFactory().get(url)
     context = {'schema': crime}
     self.mock_qs = mock.Mock()
     filt = DateFilter(req, context, self.mock_qs, *url_args[1:])
     return filt
Exemplo n.º 4
0
 def _make_filter(self, *url_args):
     crime = models.Schema.objects.get(slug='crime')
     from ebpub.db.schemafilters import TextSearchFilter
     url = filter_reverse('crime', [url_args])
     req = RequestFactory().get(url)
     context = {'schema': crime}
     sf_name = url_args[0][3:]  # 'by-foo' -> 'foo'
     sf = models.SchemaField.objects.get(name=sf_name, schema=crime)
     self.mock_qs = mock.Mock()
     filt = TextSearchFilter(req,
                             context,
                             self.mock_qs,
                             *url_args[1:],
                             schemafield=sf)
     return filt