Commit f80cdaf1 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac875] Loading of spec file

parent c2693bb8
SUBDIRS = tests
EXTRA_DIST = README
# TODO: We need to distribute the .py files and .spec files. We also need to
# install them. How to do that correctly?
......@@ -10,7 +10,7 @@ if ENABLE_PYTHON_COVERAGE
endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PLUGIN_DIR=$(abs_srcdir)/.. \
env B10_TEST_PLUGIN_DIR=$(abs_srcdir)/..:$(abs_builddir)/.. \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr \
$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
done
......
......@@ -16,7 +16,7 @@
# Make sure we can load the module, put it into path
import sys
import os
sys.path.append(os.environ["PLUGIN_DIR"])
sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
import tsig_keys
import unittest
......@@ -47,7 +47,7 @@ class TSigKeysTest(unittest.TestCase):
# Correct name
self.assertEqual("tsig_keys", spec.get_module_name())
# There are no commands, nobody would handle them anyway
self.assertEqual({}, spec.get_commands_spec())
self.assertEqual([], spec.get_commands_spec())
# There's some nonempty configuration
self.assertNotEqual({}, spec.get_config_spec())
......
......@@ -13,8 +13,10 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# TODO: Put the real spec definition here
spec = None
from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))
def check():
pass
......
......@@ -46,5 +46,8 @@ def reload():
PREFIX = "@prefix@"
DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
PLUGIN_PATHS = ["@prefix@/share/@PACKAGE@/config_plugins"]
# For testing the plugins so they can find their own spec files
if "B10_TEST_PLUGIN_DIR" in os.environ:
PLUGIN_PATHS = os.environ["B10_TEST_PLUGIN_DIR"].split(':')
reload()
......@@ -26,4 +26,4 @@ def path_search(filename, paths):
f = join(p, filename)
if exists(f):
return f
raise IOError("'" + filename + "' not found")
raise IOError("'" + filename + "' not found in " + str(paths))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment