def setup_module(module): module.store = get_store(config) # cascade to deal with differently named files depending on # anydbm impelementation try: os.unlink('links.db') except OSError: pass # not there module.links_manager = LinksManager() try: shutil.rmtree('store') except: pass def app(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app) # for @someone syntax to test correctly we need a corresponding # recipe module.store.put(Bag('cdent_public')) recipe = Recipe('cdent_public') recipe.set_recipe([('cdent_public', '')]) module.store.put(recipe)
def setup_module(module): try: shutil.rmtree('store') except: pass # !!! config['server_host'] = { 'host': 'our_test_domain', 'port': '8001', 'scheme': 'http', } from tiddlyweb.web import serve # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) environ = {'tiddlyweb.config': config} module.store = Store(config['server_store'][0], config['server_store'][1], environ) admin = User('admin') admin.add_role('ADMIN') admin.set_password('spank') module.store.put(admin) module.admin_authorization = b64encode('admin:spank') module.user_authorization = b64encode('cdent:pigdog')
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('other.0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('foo.0.0.0.0', 8080, app_fn)
def setup_module(module): # cleanup try: shutil.rmtree('store') except OSError: pass # establish web server app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) # establish store store = Store(config['server_store'][0], config['server_store'][1], environ={'tiddlyweb.config': config}) # make some stuff bag = Bag('place') store.put(bag) for i in range(1, 10): tiddler = Tiddler('tiddler%s' % i, 'place') tiddler.text = 'hi%s' store.put(tiddler) module.http = httplib2.Http()
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn) module.http = httplib2.Http() make_fake_space(store, 'thing')
def setup_intercept(self, callbacks, intercept_api=False): """Setup the WSGI intercepts. `callbacks` have to be provided to call upon request of the intercepted urls. They should be supplied as a dictionary of ((hostname, port), callback). Additionally one extra `default` callback has to be passed in, in the form ('default', callback). The `intercept_api` parameter is used to install the `httplib2` intercepts, used to intercept the lazr.restful api calls. """ self.patch_wsgi_intercept() self.intercepted = [] install_opener() self.intercept_api = intercept_api if intercept_api: install() for key, callback in callbacks.items(): if key == 'default': continue host, port = key add_wsgi_intercept(host, port, callback) self.intercepted.append((host, port))
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag1 = Bag('newtank') try: store.delete(test_bag1) except StoreError: pass module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.http = httplib2.Http() module.cookie, module.csrf = establish_user_auth(config, store, 'tankt.peermore.com:8080', 'tester')
def _initialize_app(tmpdir): # XXX: side-effecty and inscrutable instance_dir = os.path.join(tmpdir, 'instance') spawn(instance_dir, init_config, instance) old_cwd = os.getcwd() os.chdir(instance_dir) # force loading of instance's `tiddlywebconfig.py` while old_cwd in sys.path: sys.path.remove(old_cwd) sys.path.insert(0, os.getcwd()) merge_config(CONFIG, {}, reconfig=True) # XXX: should not be necessary!? CONFIG['server_host'] = { 'scheme': 'http', 'host': 'example.org', 'port': '8001', } # TODO: test with server_prefix # add symlink to templates -- XXX: hacky, should not be necessary!? templates_path = instance.__file__.split(os.path.sep)[:-2] + ['templates'] os.symlink(os.path.sep.join(templates_path), 'templates') httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('example.org', 8001, load_app)
def setup_module(module): make_test_env(module) # we have to have a function that returns the callable, # Selector just _is_ the callable httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http()
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag = Bag('editable') try: store.delete(test_bag) except StoreError: pass store.put(test_bag) module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.http = httplib2.Http() module.csrf = None
def initialize_app(): app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setup_module(module): module.store = Store('ramstore', {}, {}) config['server_store'] = ['ramstore', {}] def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag1 = Bag('newtank') try: store.delete(test_bag1) except StoreError: pass module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.http = httplib2.Http() module.cookie, module.csrf = establish_user_auth( config, store, 'tankt.peermore.com:8080', 'tester')
def initialize(self, request, connectors): # Install the WSGI interception layer. install() # Unload django. for module in list(sys.modules.keys()): if module and 'django' in module: del sys.modules[module] # Reset and clear all global cache in armet. from armet import decorators decorators._resources = {} # decorators._handlers = {} armet.use.config = {} # Re-initialize the configuration. armet.use(connectors=connectors, debug=True) prefix = 'tests.armet.connectors.' callback = None if 'model' in connectors: # Initialize the database access layer. model = import_module(prefix + connectors['model']) callback = model.model_setup # Add the models module so that it can be generically imported. sys.modules[prefix + 'models'] = model # Initialize the http access layer. http = import_module(prefix + connectors['http']) http.http_setup(connectors, self.host, self.port, callback=callback) # Add a finalizer to teardown the http layer. request.addfinalizer(lambda: http.http_teardown(self.host, self.port))
def setup_module(module): global TESTS make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http() TESTS = yaml.load(open('../test/httptest.yaml'))
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) module.http = httplib2.Http()
def setup_module(module): # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setup_module(module): make_test_env(module) # we have to have a function that returns the callable, # Selector just _is_ the callable make_fake_space(module.store, 'cdent') httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
def initialize_app(): app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)
def setUp(self): super(BaseComplianceCase, self).setUp() warnings.simplefilter("error") self.addCleanup(warnings.resetwarnings) # Intercept httplib2 requests from wsgi_intercept.httplib2_intercept import install, uninstall install() self.addCleanup(uninstall)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http() make_fake_space(module.store, 'cdent') module.store.put(User('cdent'))
def setup_module(module): config['system_plugins'] = ['tiddlywebplugins.methodhack'] from tiddlyweb.web import serve def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) module.store = Store(config['server_store'][0], config['server_store'][1], {'tiddlyweb.config': config})
def __init__(self, *args, **kwargs): wsgiapp = loadapp('config:test.ini', relative_to=conf_dir) self.app = wsgiapp from twirlip.lib.notification import notification_methods notification_methods['Email'] = mock_email httplib2_intercept.install() add_wsgi_intercept('testserver.example.com', 80, TwirlipServerFixture) TestCase.__init__(self, *args, **kwargs)
def setup_module(module): module.config_dict = closet.config from closet.putter import urls # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return urls #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setup_module(module): from tiddlyweb.web import serve serve.config['extractors'].append('saliva') def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) reset_textstore() module.store = _teststore() muchdata(module.store)
def setup_web(): """ set up TiddlyWeb to run as a mock server This is required to get selector loaded """ def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('test_domain', 8001, app_fn)
def setup_module(module): make_test_env(module) from tiddlyweb.config import config module.secret = config['secret'] httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) user = User('cdent') user.set_password('cow') module.store.put(user) user = User('fnd') module.store.put(user)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn) make_fake_space(store, 'thing') module.http = httplib2.Http() tiddler = Tiddler('OhHi', 'thing_public') tiddler.text = '!Hi\n' store.put(tiddler)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept("thing.0.0.0.0", 8080, app_fn) make_fake_space(store, "thing") module.http = httplib2.Http() tiddler = Tiddler("OhHi", "thing_public") tiddler.text = "!Hi\n" store.put(tiddler)
def setup_module(module): from .fixtures import populate_store module.environ = {"tiddlyweb.config": config} config["system_plugins"].append("tiddlywebplugins.webdav") populate_store() httplib2_intercept.install() add_wsgi_intercept(HOSTNAME, PORT, _app) module.client = httplib2.Http()
def setup_module(module): from .fixtures import populate_store module.environ = { "tiddlyweb.config": config } config["system_plugins"].append("tiddlywebplugins.webdav") populate_store() httplib2_intercept.install() add_wsgi_intercept(HOSTNAME, PORT, _app) module.client = httplib2.Http()
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('foo.0.0.0.0', 8080, app_fn) module.http = httplib2.Http() user = User('foo') user.set_password('foobar') store.put(user) make_fake_space(store, 'foo')
def setup_module(module): from tiddlyweb.web import serve # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) reset_textstore() module.store = _teststore()
def setup_module(module): make_test_env(module, hsearch=True) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('fnd.0.0.0.0', 8080, app_fn) make_fake_space(module.store, 'cdent') make_fake_space(module.store, 'fnd') user = User('cdent') user.set_password('cow') module.store.put(user) module.http = httplib2.Http()
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('foo.0.0.0.0', 8080, app_fn) user = User('thingone') user.set_password('how') store.put(user) user = User('thingtwo') user.set_password('how') store.put(user) module.http = httplib2.Http()
def setup_module(module): from tiddlyweb.web import serve def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) try: shutil.rmtree('store') except OSError: # it's not there pass module.http = httplib2.Http()
def setupRest(self): from pybble.app import make_cfg_app super(WebTC,self).setupRest() global main_app app = make_cfg_app() main_app = SubdomainDispatcher(app) if not skip_httpclient: http_client_intercept.install() if not skip_httplib2: httplib2_intercept.install() if not skip_requests: requests_intercept.install() if not skip_urllib: urllib_intercept.install_opener()
def setup_module(module): from tiddlyweb.web import serve # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) reset_textstore() module.store = _teststore() muchdata(module.store)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) make_fake_space(module.store, 'fnd') make_fake_space(module.store, 'cdent') make_fake_space(module.store, 'psd') users = {'fnd': 'foo', 'cdent': 'bar', 'psd': 'baz'} for username, password in users.items(): user = User(username) user.set_password(password) module.store.put(user)
def initialize_app(config, domain='our_test_domain', port=8001): """ Setup a wsgi intercepted server. """ config['server_host'] = { 'scheme': 'http', 'host': domain, 'port': str(port), } app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept(domain, port, app_fn)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('bar.example.com', 8080, app_fn) make_fake_space(module.store, 'cdent') user = User('cdent') user.set_password('cow') module.store.put(user) module.auth = b64encode('cdent:cow') user = User('fnd') user.set_password('pig') module.store.put(user) module.badauth = b64encode('fnd:pig') module.http = httplib2.Http()
def setup_module(module): make_test_env(module) httplib2_intercept.install() from tiddlyweb.config import config config['blacklisted_spaces'] = ['scrappy'] wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) make_fake_space(module.store, 'cdent') user = User('cdent') user.set_password('cow') module.store.put(user) user = User('fnd') user.set_password('bird') module.store.put(user) user = User('psd') user.set_password('cat') module.store.put(user)
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http() bag = Bag('place') store.put(bag) manifest = Tiddler('manifest', 'place') manifest.type = MANIFEST_TYPE manifest.text = BASE_MANIFEST store.put(manifest) notmanifest = Tiddler('notmanifest', 'place') manifest.text = 'oh hi' store.put(notmanifest)
def setup_module(module): try: shutil.rmtree('store') shutil.rmtree('binarystore') except: pass from tiddlyweb.web import serve def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.store = get_store(config) module.http = httplib2.Http() bag = store.put(Bag('kittens'))