Example #1
0
 def test_parameters(self):
     # normal api
     res = ([], {'firstresult': 1, 'totalresults': 0})
     self.env[
         'QUERY_STRING'] = "rdf_type=bibo:Standard&dcterms_title=Hello+World&dcterms_issued=2014-06-30&schema_free=true"
     config = {
         'connect.return_value':
         Mock(
             **{
                 'query.return_value': res,
                 'schema.return_value': {
                     'dcterms_issued': fulltextindex.Datetime(),
                     'schema_free': fulltextindex.Boolean()
                 }
             })
     }
     want = {
         'q': None,
         'dcterms_title': "Hello World",
         'dcterms_issued': datetime.datetime(2014, 6, 30, 0, 0, 0),
         'schema_free': True,
         'rdf_type':
         'bibo:Standard',  # FIXME: should be http://purl.org/ontology/bibo/Standard -- but requires that self.repos in wsgiapp is set up
         'pagenum': 1,
         'pagelen': 10,
         'ac_query': False,
         'boost_types': None,
         'exclude_types': None
     }
     with patch('ferenda.wsgiapp.FulltextIndex', **config):
         status, headers, content = self.call_wsgi(self.env)
         config['connect.return_value'].query.assert_called_once_with(
             **want)
Example #2
0
    def test_parameters_legacy(self):
        # legacy api
        res = ([], {'firstresult': 1,
                    'totalresults': 0})
        # FIXME: we leave out free=true (should map to schema_free=True)
        self.builder.query_string = "type=Standard&title=Hello+World&issued=2014-06-30&schema_free=true"
        self.app.config.legacyapi = True
        config = {'connect.return_value': 
                  Mock(**{'query.return_value': res,
                          'schema.return_value': {'dcterms_issued': fulltextindex.Datetime(),
                                                  'schema_free': fulltextindex.Boolean(),
                                                  'dcterms_title': None,
                                                  'rdf_type': None}})}

        want = {'q': None,
                'dcterms_title': "Hello World",
                'dcterms_issued': datetime.datetime(2014,6,30,0,0,0),
                'schema_free': True,
                'rdf_type': '*Standard', # should be bibo:Standard or even http://purl.org/ontology/bibo/Standard, but requires proper context handling to work
                'pagenum': 1,
                'pagelen': 10,
                'ac_query': False,
                'boost_repos': None,
                'exclude_repos': None,
                'include_fragments': None}

        with patch('ferenda.wsgiapp.FulltextIndex', **config):
            status, headers, content = self.call_wsgi()
            config['connect.return_value'].query.assert_called_once_with(**want)
Example #3
0
                   'use_for_toc': True,
                   'use_for_feed': True,
                   'selector': Facet.resourcelabel,
                   'key': Facet.resourcelabel,
                   'identificator': Facet.term,
                   'dimension_type': 'ref',
                   'pagetitle': 'Documents published by %(selected)s'
 },
 DCTERMS.references: {  # NB: this is a single URI reference w/o label
                   'indexingtype': fulltextindex.URI(),
                   'use_for_toc': False,
 },
 DCTERMS.issued: {
                   'label': "Sorted by publication year",
                   'pagetitle': "Documents published in %(selected)s",
                   'indexingtype': fulltextindex.Datetime(),
                   'toplevel_only': True,
                   'use_for_toc': True,
                   'selector': Facet.year,
                   'key': Facet.defaultselector,
                   'identificator': Facet.year,
                   'selector_descending': False,
                   'key_descending': False,
                   'dimension_type': "year"
 },
 DC.subject: {
                   # eg. one or more string literals (not URIRefs),
                   'indexingtype': fulltextindex.Keyword(),
                   'multiple_values': True,
                   'toplevel_only': True,
                   'use_for_toc': True,