def test_server_hostport(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "port = 4444\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getint('server', 'port'), 4444)
def test_server_ipv4(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "force-ipv4 = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getboolean('server', 'force-ipv4'), True)
def test_server_hostname(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "host-name = testhost\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.get('server', 'host-name', 1), 'testhost')
def test_server_maxtriples(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "max-triples = 1200\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getint('server', 'max-triples'), 1200)
def test_server_flashallow(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "flash-allow = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getboolean('server', 'flash-allow'), True)
def test_rdf_database_forceinit(self): fhandler = StringIO() fhandler.writelines(["[rdf_database]\n", "force-init = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getboolean('rdf_database', 'force-init'), True)
def test_logging_multiple_loggers(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "loggers = ktbs rdfrest\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.get('logging', 'loggers', 1), 'ktbs rdfrest')
def test_logging_filelevel(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "file-level = WARNING\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.get('logging', 'file-level', 1), 'WARNING')
def test_server_basepath(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "base-path = myktbsroot/\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.get('server', 'base-path', 1), 'myktbsroot/')
def test_logging_consolelevel(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "console-level = DEBUG\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.get('logging', 'console-level', 1), 'DEBUG')
def test_logging_filelevel(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "file-level = WARNING\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('logging', 'file-level', 1) == 'WARNING'
def test_server_hostname(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "host-name = testhost\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('server', 'host-name', 1) == 'testhost'
def test_server_maxbytes(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "max-bytes = 1234\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getint('server', 'max-bytes') == 1234
def test_server_ipv4(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "force-ipv4 = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getboolean('server', 'force-ipv4') == True
def test_server_maxtriples(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "max-triples = 1200\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getint('server', 'max-triples') == 1200
def test_logging_filename(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "filename = /var/log/myktbslogs.log\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('logging', 'filename', 1) == '/var/log/myktbslogs.log'
def test_server_basepath(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "base-path = myktbsroot/\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('server', 'base-path', 1) == 'myktbsroot/'
def test_rdf_database_forceinit(self): fhandler = StringIO() fhandler.writelines(["[rdf_database]\n", "force-init = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getboolean('rdf_database', 'force-init') == True
def test_rdf_database_repository(self): fhandler = StringIO() fhandler.writelines(["[rdf_database]\n", "repository = /var/myktbs/\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('rdf_database', 'repository', 1) == '/var/myktbs/'
def test_logging_multiple_loggers(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "loggers = ktbs rdfrest\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('logging', 'loggers', 1) == 'ktbs rdfrest'
def test_logging_one_logger(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "loggers = ktbs\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('logging', 'loggers', 1) == 'ktbs'
def test_logging_consolelevel(self): fhandler = StringIO() fhandler.writelines(["[logging]\n", "console-level = DEBUG\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.get('logging', 'console-level', 1) == 'DEBUG'
def test_plugins_one_item(self): fhandler = StringIO() fhandler.writelines(["[plugins]\n", "test_preproc = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) # There's a default plugin in the config post_via_get eq_(ktbs_config.options('plugins'), ['post_via_get', 'test_preproc'])
def test_server_corsalloworigin(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "cors-allow-origin = xxx\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getboolean('server', 'cors-allow-origin'), True) pass
def test_server_flashallow(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "flash-allow = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getboolean('server', 'flash-allow') == True
def test_server_hostport(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "port = 4444\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getint('server', 'port') == 4444
def test_plugins_one_item(self): fhandler = StringIO() fhandler.writelines(["[plugins]\n", "test_preproc = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) # There's a default plugin in the config post_via_get assert ktbs_config.options('plugins'), ['post_via_get' == 'test_preproc']
def test_server_corsalloworigin(self): fhandler = StringIO() fhandler.writelines(["[server]\n", "cors-allow-origin = xxx\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getboolean('server', 'cors-allow-origin') == True pass
def test_server_nocache(self): """Be careful in ConfigParser this parameter is treated as boolean. In standalone, it is defined as an integer !!! """ fhandler = StringIO() fhandler.writelines(["[server]\n", "no-cache = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) eq_(ktbs_config.getboolean('server', 'no-cache'), True)
def test_ns_prefix_one_item(self): fhandler = StringIO() fhandler.writelines(["[ns_prefix]\n", "foaf = http://xmlns.com/foaf/0.1/\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) # In this case, foaf is the first prefix added before the 2 # default ones added by get_ktbs_configuration() assert ktbs_config.options('ns_prefix'), ['foaf', '_' == 'skos'] assert ktbs_config.get('ns_prefix', 'foaf', 1) == 'http://xmlns.com/foaf/0.1/'
def test_server_nocache(self): """Be careful in ConfigParser this parameter is treated as boolean. In standalone, it is defined as an integer !!! """ fhandler = StringIO() fhandler.writelines(["[server]\n", "no-cache = true\n"]) fhandler.seek(0) ktbs_config = get_ktbs_configuration(fhandler) assert ktbs_config.getboolean('server', 'no-cache') == True
def setup(self): super(HttpKtbsTestCaseMixin, self).setup() ktbs_config = get_ktbs_configuration() app = HttpFrontend(self.service, ktbs_config) #app = HttpFrontend(self.service, cache_control="max-age=60") try: httpd = make_server("localhost", 12345, app, handler_class=StdoutHandler) thread = Thread(target=httpd.serve_forever) thread.start() self.httpd = httpd self.my_ktbs = HttpClientCore.factory("http://localhost:12345/", [KTBS.KtbsRoot]) assert isinstance(self.my_ktbs, KtbsRootMixin) except: self.teardown() raise
def setUp(): global ARGS, BASE if ARGS.ktbs is None: my_ktbs = make_ktbs() ARGS.ktbs = my_ktbs.uri elif ARGS.ktbs.startswith("file://"): ktbs_config = get_ktbs_configuration() ktbs_config.set('rdf_database', 'repository', ARGS.ktbs[7:]) my_ktbs = make_ktbs(ktbs_config) ARGS.ktbs = my_ktbs.uri else: my_ktbs = get_ktbs(ARGS.ktbs) BASE = my_ktbs.create_base(label="stress-ktbs-base") model = BASE.create_model("m") model.unit = KTBS.millisecond BASE.create_stored_trace("t/", "m", "2012-09-06T00:00:00Z", default_subject="Alice")
def setUp(self): super(HttpKtbsTestCaseMixin, self).setUp() ktbs_config = get_ktbs_configuration() app = HttpFrontend(self.service, ktbs_config) #app = HttpFrontend(self.service, cache_control="max-age=60") try: httpd = make_server("localhost", 12345, app, handler_class=StdoutHandler) thread = Thread(target=httpd.serve_forever) thread.start() self.httpd = httpd self.my_ktbs = HttpClientCore.factory("http://localhost:12345/", [KTBS.KtbsRoot]) assert isinstance(self.my_ktbs, KtbsRootMixin) except: self.tearDown() raise
def setup(self): ktbs_config = get_ktbs_configuration() ktbs_config.set('server', 'port', '12345') self.service = KtbsService(ktbs_config) self.my_ktbs = self.service.get(self.service.root_uri, [KTBS.KtbsRoot])
from rdfrest.cores.http_client import HttpClientCore from rdfrest.http_server import HttpFrontend from rdfrest.util.iso8601 import UTC from ktbs.api.ktbs_root import KtbsRootMixin from ktbs.engine.resource import METADATA from ktbs.engine.service import KtbsService from ktbs.methods.filter import LOG as FILTER_LOG from ktbs.namespace import KTBS from ktbs.time import lit2datetime from ktbs.config import get_ktbs_configuration from ktbs.engine.service import make_ktbs from .utils import StdoutHandler # plugin must be loaded for all kTBS tests import ktbs.plugins.meth_external ktbs.plugins.meth_external.start_plugin(get_ktbs_configuration()) cmdline = "echo" class KtbsTestCase(object): my_ktbs = None service = None def setup(self): ktbs_config = get_ktbs_configuration() ktbs_config.set('server', 'port', '12345') self.service = KtbsService(ktbs_config) self.my_ktbs = self.service.get(self.service.root_uri, [KTBS.KtbsRoot]) def teardown(self):
from rdfrest.cores.http_client import HttpClientCore from rdfrest.http_server import HttpFrontend from rdfrest.util.iso8601 import UTC from ktbs.api.ktbs_root import KtbsRootMixin from ktbs.engine.resource import METADATA from ktbs.engine.service import KtbsService from ktbs.methods.filter import LOG as FILTER_LOG from ktbs.namespace import KTBS from ktbs.time import lit2datetime from ktbs.config import get_ktbs_configuration from ktbs.engine.service import make_ktbs from .utils import StdoutHandler # plugin must be loaded for all kTBS tests import ktbs.plugins.meth_external ktbs.plugins.meth_external.start_plugin(get_ktbs_configuration()) cmdline = "echo" class KtbsTestCase(object): my_ktbs = None service = None def setUp(self): ktbs_config = get_ktbs_configuration() ktbs_config.set('server', 'port', '12345') self.service = KtbsService(ktbs_config) self.my_ktbs = self.service.get(self.service.root_uri, [KTBS.KtbsRoot])
def setUp(self): ktbs_config = get_ktbs_configuration() ktbs_config.set('server', 'port', '12345') self.service = KtbsService(ktbs_config) self.my_ktbs = self.service.get(self.service.root_uri, [KTBS.KtbsRoot])