[ckan-changes] commit/ckanext-solr: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Aug 16 17:13:48 UTC 2011


2 new changesets in ckanext-solr:

http://bitbucket.org/okfn/ckanext-solr/changeset/0607039ed60d/
changeset:   0607039ed60d
user:        John Glover
date:        2011-08-16 19:13:19
summary:     Remove print statement
affected #:  1 file (21 bytes)

--- a/tests/test_package_search.py	Tue Aug 16 17:48:22 2011 +0100
+++ b/tests/test_package_search.py	Tue Aug 16 18:13:19 2011 +0100
@@ -240,7 +240,6 @@
         options.filter_by_openness = only_open
         options.filter_by_downloadable = only_downloadable
         result = self.backend.query_for(model.Package).run(query=unicode(terms))
-        print result
         pkgs = result['results']
         count = result['count']
         assert count == expected_count, (count, expected_count)


http://bitbucket.org/okfn/ckanext-solr/changeset/d408e8910a0b/
changeset:   d408e8910a0b
user:        John Glover
date:        2011-08-16 19:13:36
summary:     Update tests for synchronous search
affected #:  1 file (1.1 KB)

--- a/tests/test_package_search_synchronous_update.py	Tue Aug 16 18:13:19 2011 +0100
+++ b/tests/test_package_search_synchronous_update.py	Tue Aug 16 18:13:36 2011 +0100
@@ -9,10 +9,6 @@
 
     @classmethod
     def setup_class(cls):
-        # TODO: synchronous_search plugin not working with solr, fix
-        from ckan.tests import SkipTest
-        raise SkipTest("Synchronous search not implemented for solr yet")
-
         # Force a garbage collection to trigger issue #695
         import gc
         gc.collect()
@@ -23,56 +19,99 @@
         plugins.load('synchronous_search')
 
         cls.new_pkg_dict = {
-             "name": "council-owned-litter-bins",
-             "notes": "Location of Council owned litter bins within Borough.",
-             "resources": [{"description": "Resource locator",
-                            "format": "Unverified",
-                            "url": "http://www.barrowbc.gov.uk"}],
-             "tags": ["Utility and governmental services"],
-             "title": "Council Owned Litter Bins",
-            "extras": {"INSPIRE": "True",
-                        "bbox-east-long": "-3.12442",
-                        "bbox-north-lat": "54.218407",
-                        "bbox-south-lat": "54.039634",
-                        "bbox-west-long": "-3.32485",
-                        "constraint": "conditions unknown; (e) intellectual property rights;",
-                        "dataset-reference-date": [{"type": "creation",
-                                                    "value": "2008-10-10"},
-                                                   {"type": "revision",
-                                                    "value": "2009-10-08"}],
-                        "guid": "00a743bf-cca4-4c19-a8e5-e64f7edbcadd",
-                        "metadata-date": "2009-10-16",
-                        "metadata-language": "eng",
-                        "published_by": 0,
-                        "resource-type": "dataset",
-                        "spatial-reference-system": "wee",
-                        "temporal_coverage-from": "1977-03-10T11:45:30",
-                        "temporal_coverage-to": "2005-01-15T09:10:00"}
-         }
+            "name": "council-owned-litter-bins",
+            "notes": "Location of Council owned litter bins within Borough.",
+            "resources": [{"description": "Resource locator",
+                           "format": "Unverified",
+                           "url": "http://www.barrowbc.gov.uk"}],
+            "tags": ["Utility and governmental services"],
+            "title": "Council Owned Litter Bins",
+            "extras": {
+                "INSPIRE": "True",
+                "bbox-east-long": "-3.12442",
+                "bbox-north-lat": "54.218407",
+                "bbox-south-lat": "54.039634",
+                "bbox-west-long": "-3.32485",
+                "constraint": "conditions unknown; (e) intellectual property rights;",
+                "dataset-reference-date": [{"type": "creation",
+                                            "value": "2008-10-10"},
+                                           {"type": "revision",
+                                            "value": "2009-10-08"}],
+                "guid": "00a743bf-cca4-4c19-a8e5-e64f7edbcadd",
+                "metadata-date": "2009-10-16",
+                "metadata-language": "eng",
+                "published_by": 0,
+                "resource-type": "dataset",
+                "spatial-reference-system": "wee",
+                "temporal_coverage-from": "1977-03-10T11:45:30",
+                "temporal_coverage-to": "2005-01-15T09:10:00"
+            }
+        }
+
+    def _create_package(self, package=None):
+        rev = model.repo.new_revision()
+        rev.author = u'tester'
+        rev.message = u'Creating test data'
+        if not package:
+            package = model.Package()
+
+        relationship_attr = ['extras', 'resources', 'tags']
+        package_properties = {}
+        for key, value in self.new_pkg_dict.iteritems():
+            if key not in relationship_attr:
+                setattr(package, key, value)
+
+        tags = self.new_pkg_dict.get('tags', [])
+        for tag in tags:
+            package.add_tag_by_name(tag, autoflush=False)
+        
+        for resource_dict in self.new_pkg_dict.get("resources", []):
+            resource = model.Resource(**resource_dict)
+            package.resources[:] = []
+            package.resources.append(resource)
+
+        for key, value in self.new_pkg_dict.get("extras", {}).iteritems():
+            extra = model.PackageExtra(key=key, value=value)
+            package._extras[key] = extra
+
+        model.Session.add(package)
+        model.setup_default_user_roles(package, [])
+        model.repo.commit_and_remove()
+        return package
+
+    def _remove_package(self):
+        package = model.Package.by_name('council-owned-litter-bins')
+        model.Session.delete(package)
+        model.Session.commit()
 
     def test_01_search_table_count(self):
         self._check_search_results('', 2)
 
     def test_02_add_package_from_dict(self):
-        CreateTestData.create_arbitrary(self.new_pkg_dict)
+        self._create_package()
         self._check_search_results('', 3)
         self._check_search_results('wee', 1, ['council-owned-litter-bins'])
-        package = model.Package.by_name('council-owned-litter-bins')
-        model.Session.delete(package)
-        model.Session.commit()
+        self._remove_package()
 
     def test_03_update_package_from_dict(self):
-        CreateTestData.create_arbitrary(self.new_pkg_dict)
+        self._create_package()
         package = model.Package.by_name('council-owned-litter-bins')
         self.new_pkg_dict['name'] = 'new_name'
         self.new_pkg_dict['extras']['published_by'] = 'meeeee'
-        CreateTestData.create_arbitrary(self.new_pkg_dict)
+        self._create_package(package)
         self._check_search_results('', 3)
         self._check_search_results('meeeee', 1, ['new_name'])
 
+        package = model.Package.by_name('new_name')
+        self.new_pkg_dict['name'] = 'council-owned-litter-bins'
+        self._create_package(package)
+        self._check_search_results('', 3)
+        self._check_search_results('wee', 1, ['council-owned-litter-bins'])
+        self._remove_package()
+
     def test_04_delete_package_from_dict(self):
-        package = model.Package.by_name('new_name')
+        self._create_package()
+        package = model.Package.by_name('council-owned-litter-bins')
         assert package
-        model.Session.delete(package)
-        model.Session.commit()
+        self._remove_package()
         self._check_search_results('', 2)

Repository URL: https://bitbucket.org/okfn/ckanext-solr/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list