Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
 def facets(self):
     return [
         Facet(RDF.type),  # fulltextindex.URI
         Facet(DCTERMS.title),  # fulltextindex.Text(boost=4)
         Facet(DCTERMS.identifier),  # fulltextindex.Label(boost=16)
         Facet(DCTERMS.issued),  # fulltextindex.Datetime()
         Facet(DCTERMS.issued,
               indexingtype=fulltextindex.Boolean(),
               selector=self.is_april_fools,
               dimension_type="value",
               dimension_label="aprilfools"),
         Facet(DCTERMS.publisher),  # fulltextindex.Resource()
         Facet(DC.subject),  # fulltextindex.Keywords()
         Facet(SCHEMA.free)  # fulltextindex.Boolean()
     ]
Esempio n. 4
0
                      'multiple_values': True,
                      'toplevel_only': True,
                      'use_for_toc': True,
                      'selector': Facet.defaultselector,
                      'key': Facet.defaultselector,
                      'multiple_values': True,
                      'dimension_type': 'value',
    },
    DCTERMS.subject: {
    # eg. one or more URIRefs + labels
    'indexingtype': fulltextindex.Resource(),
    'multiple_values': True,
    'toplevel_only': True,
    'use_for_toc': True,
    'selector': Facet.resourcelabel,
    'key': Facet.resourcelabel,
    'identificator': Facet.term,
    'multiple_values': True,
    'dimension_type': 'ref',
    },
    SCHEMA.free: {  # "A flag to signal that the publication is accessible for free."
    'indexingtype': fulltextindex.Boolean(),
                    'toplevel_only': True,
                    'use_for_toc': True,
                    'use_for_feed': True,
                    'selector': Facet.booleanvalue,
                    'key': Facet.defaultselector,
                    'dimension_type': 'value'
    }
                  }