-
Notifications
You must be signed in to change notification settings - Fork 2k
/
test_solr_schema_version.py
53 lines (33 loc) · 1.52 KB
/
test_solr_schema_version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from ckan.tests import TestController
class TestSolrSchemaVersionCheck(TestController):
@classmethod
def setup_class(cls):
cls.root_dir = os.path.dirname(os.path.realpath(__file__))
def _get_current_schema(self):
current_schema = os.path.join(self.root_dir,'..','..','config','solr','schema.xml')
return current_schema
def test_current_schema_exists(self):
current_schema = self._get_current_schema()
assert os.path.exists(current_schema)
def test_solr_schema_version_check(self):
from ckan.lib.search import check_solr_schema_version, SearchError
schema_file = self._get_current_schema()
# Check that current schema version schema is supported
assert check_solr_schema_version(schema_file)
# An exception is thrown if version could not be extracted
try:
schema_file = os.path.join(self.root_dir,'solr','schema-no-version.xml')
check_solr_schema_version(schema_file)
#Should not happen
assert False
except SearchError,e:
assert 'Could not extract version info' in str(e)
# An exception is thrown if the schema version is not supported
try:
schema_file = os.path.join(self.root_dir,'solr','schema-wrong-version.xml')
check_solr_schema_version(schema_file)
#Should not happen
assert False
except SearchError,e:
assert 'SOLR schema version not supported' in str(e)