def setUp(self): if self.network and os.getenv('IBID_NETWORKLESS_TEST') is not None: raise unittest.SkipTest('test uses network') ibid.config = FileConfig(locate_resource('ibid.test', 'test.ini')) if self.load_configured is None: self.load_configured = not self.load if self.load_base: if 'core' not in self.load: self.load += ['core'] if 'core.RateLimit' not in self.noload: self.noload += ['core.RateLimit'] self._create_database() ibid.reload_reloader() ibid.reloader.reload_databases() ibid.reloader.reload_dispatcher() ibid.reloader.load_processors(self.load, self.noload, self.load_configured) ibid.auth = TestAuth() self.source = u'test_source_' + unicode(id(self)) ibid.sources[self.source] = TestSource() session = ibid.databases.ibid() self.identity = Identity(self.source, self.username) session.save(self.identity) session.commit() self.identity = session.query(Identity) \ .filter_by(identity=self.username).one() session.close()
def FileConfig(filename): spec = file(locate_resource('ibid', 'configspec.ini'), 'r') configspec = ConfigObj(spec, list_values=False, encoding='utf-8') config = ConfigObj(filename, configspec=configspec, interpolation='Template', encoding='utf-8') config.validate(Validator()) logging.getLogger('core.config').info(u"Loaded configuration from %s", filename) return config
def __init__(self, name): IbidSourceFactory.__init__(self, name) root = Plugin(name) root.putChild('', Index(name)) root.putChild('message', Message(name)) root.putChild('static', static.File(locate_resource('ibid', 'static'))) root.putChild('RPC2', XMLRPC()) root.putChild('SOAP', SOAP()) self.site = server.Site(root)
def setUp(self): super(PluginTestCase, self).setUp() if sqlalchemy.__version__ > '0.6.0': raise unittest.SkipTest( "PluginTestCase doesn't work with SQLAlchemy 0.6") if self.network and os.getenv('IBID_NETWORKLESS_TEST') is not None: raise unittest.SkipTest('test uses network') ibid.config = FileConfig(locate_resource('ibid.test', 'test.ini')) if self.load_configured is None: self.load_configured = not self.load if self.load_base: if 'core' not in self.load: self.load += ['core'] if 'core.RateLimit' not in self.noload: self.noload += ['core.RateLimit'] self._create_database() ibid.reload_reloader() ibid.reloader.reload_databases() ibid.reloader.reload_dispatcher() ibid.reloader.load_processors(self.load, self.noload, self.load_configured) ibid.auth = TestAuth() self.source = u'test_source_' + unicode(id(self)) ibid.sources[self.source] = TestSource() session = ibid.databases.ibid() self.identity = Identity(self.source, self.username) session.add(self.identity) session.commit() self.identity = session.query(Identity) \ .filter_by(identity=self.username).one() session.close()
def setUp(self): super(PluginTestCase, self).setUp() if sqlalchemy.__version__ > "0.6.0": raise unittest.SkipTest("PluginTestCase doesn't work with SQLAlchemy 0.6") if self.network and os.getenv("IBID_NETWORKLESS_TEST") is not None: raise unittest.SkipTest("test uses network") ibid.config = FileConfig(locate_resource("ibid.test", "test.ini")) if self.load_configured is None: self.load_configured = not self.load if self.load_base: if "core" not in self.load: self.load += ["core"] if "core.RateLimit" not in self.noload: self.noload += ["core.RateLimit"] self._create_database() ibid.reload_reloader() ibid.reloader.reload_databases() ibid.reloader.reload_dispatcher() ibid.reloader.load_processors(self.load, self.noload, self.load_configured) ibid.auth = TestAuth() self.source = u"test_source_" + unicode(id(self)) ibid.sources[self.source] = TestSource() session = ibid.databases.ibid() self.identity = Identity(self.source, self.username) session.add(self.identity) session.commit() self.identity = session.query(Identity).filter_by(identity=self.username).one() session.close()
import logging import os from twisted.web import server, resource, static, xmlrpc, soap from twisted.application import internet from twisted.internet import reactor from jinja2 import Environment, FileSystemLoader import ibid from ibid.source import IbidSourceFactory from ibid.event import Event from ibid.config import Option, IntOption from ibid.utils import locate_resource templates = Environment(loader=FileSystemLoader( os.path.abspath(locate_resource('ibid', 'templates')))) class Index(resource.Resource): def __init__(self, name, *args, **kwargs): resource.Resource.__init__(self, *args, **kwargs) self.name = name self.log = logging.getLogger('source.%s' % name) self.template = templates.get_template('index.html') def render_GET(self, request): return self.template.render(rpc=ibid.rpc.keys()).encode('utf-8') class Message(resource.Resource): def __init__(self, name, *args, **kwargs):
def setUp(self): super(TestCase, self).setUp() if self.network and os.getenv('IBID_NETWORKLESS_TEST') is not None: raise unittest.SkipTest('test uses network') ibid.config = FileConfig(locate_resource('ibid.test', 'test.ini'))
def setUp(self): super(TestCase, self).setUp() if self.network and os.getenv("IBID_NETWORKLESS_TEST") is not None: raise unittest.SkipTest("test uses network") ibid.config = FileConfig(locate_resource("ibid.test", "test.ini"))
import logging from twisted.web import server, resource, static, xmlrpc, soap from twisted.application import internet from twisted.internet import reactor from jinja import Environment, FileSystemLoader import ibid from ibid.source import IbidSourceFactory from ibid.event import Event from ibid.config import Option, IntOption from ibid.utils import locate_resource templates = Environment(loader=FileSystemLoader( locate_resource('ibid', 'templates'))) class Index(resource.Resource): def __init__(self, name, *args, **kwargs): resource.Resource.__init__(self, *args, **kwargs) self.name = name self.log = logging.getLogger('source.%s' % name) self.template = templates.get_template('index.html') def render_GET(self, request): return self.template.render(rpc=ibid.rpc.keys()).encode('utf-8') class Message(resource.Resource): def __init__(self, name, *args, **kwargs):