示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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')
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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')
示例#8
0
    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')
示例#9
0
    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/')
示例#10
0
    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')
示例#11
0
    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'
示例#12
0
    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'
示例#13
0
    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
示例#14
0
    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
示例#15
0
    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
示例#16
0
    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'
示例#17
0
    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/'
示例#18
0
    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
示例#19
0
    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/'
示例#20
0
    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'
示例#21
0
    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'
示例#22
0
    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'
示例#23
0
    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'])
示例#24
0
    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
示例#25
0
    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
示例#26
0
    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
示例#27
0
    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']
示例#28
0
    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
示例#29
0
    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)
示例#30
0
    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/'
示例#31
0
    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
示例#32
0
    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
示例#33
0
文件: stress-ktbs.py 项目: ktbs/ktbs
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")
示例#34
0
    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
示例#35
0
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")
示例#36
0
 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])
示例#37
0
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):
示例#38
0
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])
示例#39
0
 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])