Пример #1
0
    def test_index(self):
        search.dispatch_by_operation("Package", {"title": "penguin"}, "new", backend=search.get_backend(backend="sql"))

        sql = "select search_vector from package_search where package_id='%s'" % self.anna.id
        vector = model.Session.execute(sql).fetchone()[0]
        assert "annakarenina" in vector, vector
        assert not "penguin" in vector, vector
Пример #2
0
    def test_index(self):

        datetime_now = datetime.now()
        pkg_dict = {
            "id": u"penguin-id",
            "title": u"penguin",
            "state": u"active",
            "private": False,
            "owner_org": None,
            "metadata_created": datetime_now.isoformat(),
            "metadata_modified": datetime_now.isoformat(),
        }
        search.dispatch_by_operation("Package", pkg_dict, "new")
        response = self.solr.query("title:penguin", fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]["index_id"] == self._get_index_id(pkg_dict["id"])
        assert response.results[0]["title"] == "penguin"

        # looks like solrpy messes with microseconds and time zones,
        # so ignore them for testing
        assert datetime_now.strftime("%Y-%m-%d %H:%M:%S") == response.results[0]["metadata_created"].strftime(
            "%Y-%m-%d %H:%M:%S"
        )
        assert datetime_now.strftime("%Y-%m-%d %H:%M:%S") == response.results[0]["metadata_modified"].strftime(
            "%Y-%m-%d %H:%M:%S"
        )
Пример #3
0
 def test_no_state_not_indexed(self):
     pkg_dict = {
         'title': 'penguin'
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 0, len(response)
Пример #4
0
    def test_index(self):

        datetime_now = datetime.now()
        pkg_dict = {
            'id': u'penguin-id',
            'title': u'penguin',
            'state': u'active',
            'type': u'dataset',
            'private': False,
            'owner_org': None,
            'metadata_created': datetime_now.isoformat(),
            'metadata_modified': datetime_now.isoformat(),
            'extras': [
                {'key': 'test_date', 'value': '2013-03-01'},
                {'key': 'test_wrong_date', 'value': 'Not a date'},
            ]
        }
        search.dispatch_by_operation('Package', pkg_dict, 'new')
        response = self.solr.query('title:penguin', fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]['index_id'] == self._get_index_id (pkg_dict['id'])
        assert response.results[0]['title'] == 'penguin'

        # looks like solrpy messes with microseconds and time zones,
        # so ignore them for testing
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_created'].strftime('%Y-%m-%d %H:%M:%S')
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_modified'].strftime('%Y-%m-%d %H:%M:%S')
Пример #5
0
 def test_no_state_not_indexed(self):
     pkg_dict = {
         'title': 'penguin'
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 0, len(response)
Пример #6
0
    def test_index(self):
        search.dispatch_by_operation('Package', {'title': 'penguin'}, 'new', 
            backend=search.get_backend(backend='sql'))

        sql = "select search_vector from package_search where package_id='%s'" % self.anna.id
        vector = model.Session.execute(sql).fetchone()[0]
        assert 'annakarenina' in vector, vector
        assert not 'penguin' in vector, vector
Пример #7
0
    def test_index(self):
        search.dispatch_by_operation('Package', {'title': 'penguin'}, 'new', 
            backend=search.get_backend(backend='sql'))

        sql = "select search_vector from package_search where package_id='%s'" % self.anna.id
        vector = model.Session.execute(sql).fetchone()[0]
        assert 'annakarenina' in vector, vector
        assert not 'penguin' in vector, vector
Пример #8
0
 def test_index(self):
     pkg_dict = {
         'id': u'penguin-id',
         'title': u'penguin',
         'state': u'active'
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 1, len(response)
     assert response.results[0]['title'] == 'penguin'
Пример #9
0
 def test_index_clear(self):
     pkg_dict = {
         'id': u'penguin-id',
         'title': u'penguin',
         'state': u'active'
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 1, len(response)
     search.index_for('Package').clear()
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 0
 def test_index_clear(self):
     pkg_dict = {
         'id': u'penguin-id',
         'title': u'penguin',
         'state': u'active',
         'metadata_created': datetime.now().isoformat(),
         'metadata_modified': datetime.now().isoformat(),
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 1, len(response)
     search.index_for('Package').clear()
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 0
Пример #11
0
 def test_index_clear(self):
     pkg_dict = {
         'id': u'penguin-id',
         'title': u'penguin',
         'state': u'active',
         'metadata_created': datetime.now().isoformat(),
         'metadata_modified': datetime.now().isoformat(),
     }
     search.dispatch_by_operation('Package', pkg_dict, 'new')
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 1, len(response)
     search.index_for('Package').clear()
     response = self.solr.query('title:penguin', fq=self.fq)
     assert len(response) == 0
Пример #12
0
    def test_index_illegal_xml_chars(self):

        pkg_dict = {
            'id': u'penguin-id',
            'title': u'\u00c3a\u0001ltimo n\u00famero penguin',
            'notes': u'\u00c3a\u0001ltimo n\u00famero penguin',
            'state': u'active',
            'metadata_created': datetime.now().isoformat(),
            'metadata_modified': datetime.now().isoformat(),
        }
        search.dispatch_by_operation('Package', pkg_dict, 'new')
        response = self.solr.query('title:penguin', fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]['index_id'] == self._get_index_id (pkg_dict['id'])
        assert response.results[0]['title'] == u'\u00c3altimo n\u00famero penguin'
Пример #13
0
    def test_index_illegal_xml_chars(self):

        pkg_dict = {
            "id": u"penguin-id",
            "title": u"\u00c3a\u0001ltimo n\u00famero penguin",
            "notes": u"\u00c3a\u0001ltimo n\u00famero penguin",
            "state": u"active",
            "private": False,
            "owner_org": None,
            "metadata_created": datetime.now().isoformat(),
            "metadata_modified": datetime.now().isoformat(),
        }
        search.dispatch_by_operation("Package", pkg_dict, "new")
        response = self.solr.query("title:penguin", fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]["index_id"] == self._get_index_id(pkg_dict["id"])
        assert response.results[0]["title"] == u"\u00c3altimo n\u00famero penguin"
    def test_index(self):

        datetime_now = datetime.now()
        pkg_dict = {
            'id':
            u'penguin-id',
            'title':
            u'penguin',
            'state':
            u'active',
            'type':
            u'dataset',
            'private':
            False,
            'owner_org':
            None,
            'metadata_created':
            datetime_now.isoformat(),
            'metadata_modified':
            datetime_now.isoformat(),
            'extras': [
                {
                    'key': 'test_date',
                    'value': '2013-03-01'
                },
                {
                    'key': 'test_wrong_date',
                    'value': 'Not a date'
                },
            ]
        }
        search.dispatch_by_operation('Package', pkg_dict, 'new')
        response = self.solr.query('title:penguin', fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]['index_id'] == self._get_index_id(
            pkg_dict['id'])
        assert response.results[0]['title'] == 'penguin'

        # looks like solrpy messes with microseconds and time zones,
        # so ignore them for testing
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[
            0]['metadata_created'].strftime('%Y-%m-%d %H:%M:%S')
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[
            0]['metadata_modified'].strftime('%Y-%m-%d %H:%M:%S')
Пример #15
0
    def test_index(self):

        datetime_now = datetime.now()
        pkg_dict = {
            'id': u'penguin-id',
            'title': u'penguin',
            'state': u'active',
            'metadata_created': datetime_now.isoformat(),
            'metadata_modified': datetime_now.isoformat(),
        }
        search.dispatch_by_operation('Package', pkg_dict, 'new')
        response = self.solr.query('title:penguin', fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]['index_id'] == self._get_index_id (pkg_dict['id'])
        assert response.results[0]['title'] == 'penguin'

        # looks like solrpy messes with microseconds and time zones,
        # so ignore them for testing
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_created'].strftime('%Y-%m-%d %H:%M:%S')
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_modified'].strftime('%Y-%m-%d %H:%M:%S')
Пример #16
0
    def test_index(self):

        datetime_now = datetime.now()
        pkg_dict = {
            'id': u'penguin-id',
            'title': u'penguin',
            'state': u'active',
            'metadata_created': datetime_now.isoformat(),
            'metadata_modified': datetime_now.isoformat(),
        }
        search.dispatch_by_operation('Package', pkg_dict, 'new')
        response = self.solr.query('title:penguin', fq=self.fq)
        assert len(response) == 1, len(response)
        assert response.results[0]['index_id'] == self._get_index_id (pkg_dict['id'])
        assert response.results[0]['title'] == 'penguin'
        
        # looks like solrpy messes with microseconds and time zones,
        # so ignore them for testing
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_created'].strftime('%Y-%m-%d %H:%M:%S')
        assert datetime_now.strftime('%Y-%m-%d %H:%M:%S') == response.results[0]['metadata_modified'].strftime('%Y-%m-%d %H:%M:%S')
Пример #17
0
 def test_index_clear(self):
     pkg_dict = {
         "id": u"penguin-id",
         "title": u"penguin",
         "state": u"active",
         "private": False,
         "owner_org": None,
         "metadata_created": datetime.now().isoformat(),
         "metadata_modified": datetime.now().isoformat(),
     }
     search.dispatch_by_operation("Package", pkg_dict, "new")
     response = self.solr.query("title:penguin", fq=self.fq)
     assert len(response) == 1, len(response)
     search.index_for("Package").clear()
     response = self.solr.query("title:penguin", fq=self.fq)
     assert len(response) == 0
     # clear whilst empty
     search.index_for("Package").clear()
     response = self.solr.query("title:penguin", fq=self.fq)
     assert len(response) == 0
Пример #18
0
 def test_no_state_not_indexed(self):
     pkg_dict = {"title": "penguin"}
     search.dispatch_by_operation("Package", pkg_dict, "new")
     response = self.solr.query("title:penguin", fq=self.fq)
     assert len(response) == 0, len(response)