def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") indexer = TestSearchIndexer() model.Session.remove() CreateTestData.create_search_test_data() # now remove a tag so we can test search with deleted tags model.repo.new_revision() gils = model.Package.by_name(u'gils') # an existing tag used only by gils self.tagname = u'registry' # we aren't guaranteed it is last ... idx = [ t.name for t in gils.tags].index(self.tagname) del gils.tags[idx] model.repo.commit_and_remove() indexer.index() self.gils = model.Package.by_name(u'gils') self.war = model.Package.by_name(u'warandpeace') self.russian = model.Tag.by_name(u'russian') self.tolstoy = model.Tag.by_name(u'tolstoy') self.backend = get_backend(backend='sql')
def setup_class(cls): if not tests.is_search_supported(): raise tests.SkipTest("Search not supported") tests.setup_test_search_index() ctd.CreateTestData.create() model.repo.new_revision() cls.vocab = model.Vocabulary(TEST_VOCAB_NAME) model.Session.add(cls.vocab) model.Session.commit() vocab_tag_1 = model.Tag('tag1', cls.vocab.id) vocab_tag_2 = model.Tag('tag2', cls.vocab.id) model.Session.add(vocab_tag_1) model.Session.add(vocab_tag_2) pkg = model.Package.get('warandpeace') pkg_tag1 = model.PackageTag(pkg, vocab_tag_1) pkg_tag2 = model.PackageTag(pkg, vocab_tag_2) model.Session.add(pkg_tag1) model.Session.add(pkg_tag2) model.Session.commit() model.Session.remove()
def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") indexer = TestSearchIndexer() model.Session.remove() CreateTestData.create_search_test_data() # now remove a tag so we can test search with deleted tags model.repo.new_revision() gils = model.Package.by_name(u'gils') # an existing tag used only by gils self.tagname = u'registry' # we aren't guaranteed it is last ... idx = [t.name for t in gils.tags].index(self.tagname) del gils.tags[idx] model.repo.commit_and_remove() indexer.index() self.gils = model.Package.by_name(u'gils') self.war = model.Package.by_name(u'warandpeace') self.russian = model.Tag.by_name(u'russian') self.tolstoy = model.Tag.by_name(u'tolstoy') self.backend = get_backend(backend='sql')
def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") self.ab = 'http://site.com/a/b.txt' self.cd = 'http://site.com/c/d.txt' self.ef = 'http://site.com/e/f.txt' self.pkgs = [ { 'name': 'pkg1', 'resources': [ { 'url': self.ab, 'description': 'This is site ab.', 'format': 'Excel spreadsheet', 'hash': 'abc-123', 'alt_url': 'alt1', 'extras': { 'size_extra': '100' }, }, { 'url': self.cd, 'description': 'This is site cd.', 'format': 'Office spreadsheet', 'hash': 'qwe-456', 'alt_url': 'alt2', 'extras': { 'size_extra': '200' }, }, ] }, { 'name': 'pkg2', 'resources': [ { 'url': self.cd, 'alt_url': 'alt1', 'description': 'This is site cd.' }, { 'url': self.ef, 'description': 'This is site ef.' }, { 'url': self.ef, 'description': 'This is site gh.' }, { 'url': self.ef, 'description': 'This is site ij.' }, ] }, ] CreateTestData.create_arbitrary(self.pkgs)
def test_mainmenu(self): # the home page does a package search so have to skip this test if # search is not supported if not is_search_supported(): from nose import SkipTest raise SkipTest("Search not supported") offset = url_for(controller='home', action='index') res = self.app.get(offset) assert 'Groups' in res, res assert 'Groups</a>' in res, res res = res.click(href='/group', index=0) assert "Dave's books" in res, res
def test_headers(self): # the home page does a package search so have to skip this test if # search is not supported if not is_search_supported(): from nose import SkipTest raise SkipTest("Search not supported") out = self.app.get('/') headers = dict(out.headers) print headers assert headers['Access-Control-Allow-Origin'] == '*' assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE, OPTIONS" assert headers['Access-Control-Allow-Headers'] == "X-CKAN-API-KEY, Authorization, Content-Type"
def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") import gc from pylons import config # Force a garbage collection to trigger issue #695 gc.collect() config['search_backend'] = 'sql' self.backend = search.get_backend() plugins.load('synchronous_search') CreateTestData.create()
def test_headers(self): # the home page does a package search so have to skip this test if # search is not supported if not is_search_supported(): from nose import SkipTest raise SkipTest("Search not supported") out = self.app.get('/') headers = dict(out.headers) print headers assert headers['Access-Control-Allow-Origin'] == '*' assert headers[ 'Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE, OPTIONS" assert headers[ 'Access-Control-Allow-Headers'] == "l, Authorization, Content-Type"
def test_solr_url_exists(self): if not is_search_supported(): from nose import SkipTest raise SkipTest("Search not supported") conn = search.make_connection() try: # solr.SolrConnection.query will throw a socket.error if it # can't connect to the SOLR instance q = conn.query("*:*", rows=1) conn.close() except socket.error, e: if not config.get('solr_url'): raise AssertionError("Config option 'solr_url' needs to be defined in this CKAN's development.ini. Default of %s didn't work: %s" % (search.DEFAULT_SOLR_URL, e)) else: raise AssertionError('SOLR connection problem. Connection defined in development.ini as: solr_url=%s Error: %s' % (config['solr_url'], e))
def setup_class(self): if not is_search_supported(): import nose raise nose.SkipTest indexer = TestSearchIndexer() CreateTestData.create() self.package_fixture_data = { 'name' : u'testpkg', 'title': 'Some Title', 'url': u'http://blahblahblah.mydomain', 'resources': [{u'url':u'http://blahblahblah.mydomain', u'format':u'', u'description':''}], 'tags': ['russion', 'novel'], 'license_id': u'gpl-3.0', 'extras': {'national_statistic':'yes', 'geographic_coverage':'England, Wales'}, } CreateTestData.create_arbitrary(self.package_fixture_data) self.base_url = self.offset('/search/package')
def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") self.ab = "http://site.com/a/b.txt" self.cd = "http://site.com/c/d.txt" self.ef = "http://site.com/e/f.txt" self.pkgs = [ { "name": "pkg1", "resources": [ { "url": self.ab, "description": "This is site ab.", "format": "Excel spreadsheet", "hash": "abc-123", "alt_url": "alt1", "extras": {"size_extra": "100"}, }, { "url": self.cd, "description": "This is site cd.", "format": "Office spreadsheet", "hash": "qwe-456", "alt_url": "alt2", "extras": {"size_extra": "200"}, }, ], }, { "name": "pkg2", "resources": [ {"url": self.cd, "alt_url": "alt1", "description": "This is site cd."}, {"url": self.ef, "description": "This is site ef."}, {"url": self.ef, "description": "This is site gh."}, {"url": self.ef, "description": "This is site ij."}, ], }, ] CreateTestData.create_arbitrary(self.pkgs)
def setup_class(self): '''NB, no search indexing started''' if not is_search_supported(): raise SkipTest("Search not supported") super(TestLoaderNoSearch, self).setup_class() self.loader = ReplaceByExtraFieldLoader(self.testclient, 'ref')
SAMPLE_FILEPATH_TEMPLATE = os.path.join(SAMPLE_PATH, 'ons_hub_sample%s.xml') def sample_filepath(id): return SAMPLE_FILEPATH_TEMPLATE % id publishers = { 'nhs-information-centre-for-health-and-social-care': 'NHS Information Centre for Health and Social Care', 'cabinet-office': 'Cabinet Office', 'department-for-children-schools-and-families': 'Department for Children, Schools and Families', 'department-for-environment-food-and-rural-affairs': 'Department for Environment, Food and Rural Affairs', 'her-majestys-treasury': 'Her Majesty\'s Treasury', 'department-of-justice': 'Ministry of Justice', 'office-for-national-statistics': 'Office for National Statistics', 'welsh-government': 'Welsh Government', } if not is_search_supported(): raise SkipTest("Search not supported") def group_names(package): return [grp.name for grp in package.get_groups()] class OnsLoaderBase(TestLoaderBase, MockDrupalCase): @classmethod def setup_class(self): try: search.clear() setup_test_search_index() super(OnsLoaderBase, self).setup_class() # make annafan a sysadmin to allow package creation rev = model.repo.new_revision()
def setup_class(self): # No TestSearchIndexer is initialised. if not is_search_supported(): raise SkipTest("Search not supported") super(TestLoaderNoIndexing, self).setup_class() self.loader = ReplaceByExtraFieldLoader(self.testclient, 'ref')
def setup_class(self): if not is_search_supported(): raise SkipTest("Search not supported") CreateTestData.create()