def prepare_test_db(self, config): # change the name of the DB used. dbinfo = config.couches['local'] # then blindly nuke it. db = get_db('local', dbinfo['name']) def del_non_test_accounts(): # 'insert_default_docs' may have created an account (eg RSS) which # may get in the way of testing; nuke any which aren't in our # config. got = db.openView('raindrop!content!all', 'megaview', key=['schema_id', 'rd.account'], include_docs=True, reduce=False) wanted_ids = set(acct['id'] for acct in config.accounts.itervalues()) to_del = [{'_id': r['doc']['_id'], '_rev': r['doc']['_rev'], '_deleted': True, } for r in got['rows'] if r['doc']['id'] not in wanted_ids] db.updateDocuments(to_del) db.deleteDB() fab_db() opts = self.get_options() bootstrap.install_views(opts, True) bootstrap.check_accounts(config) bootstrap.insert_default_docs(opts) del_non_test_accounts() if not getattr(self, 'no_sync_status_doc', False): # and make a dummy 'sync-status' doc so we don't attempt to send # welcome emails. items = {'new_items': 0, 'num_syncs': 2, } si = {'rd_key': ["raindrop", "sync-status"], 'rd_schema_id': 'rd.core.sync-status', 'rd_source': None, 'rd_ext_id': 'rd.core', 'items': items, } self.doc_model.create_schema_items([si])
doc = all_args[this].__doc__ except KeyError: print "No such command '%s':" % this continue print "Help for command '%s':" % this print doc print sys.exit(0) print "Raindrops keep falling on my head..." try: model.fab_db() # See if accounts are up-to-date. if not options.no_bootstrap: bootstrap.install_views(options) bootstrap.check_accounts() # Check if the files on the filesystem need updating. bootstrap.install_client_files(options) bootstrap.insert_default_docs(options) bootstrap.update_apps() global g_pipeline, g_conductor assert g_pipeline is None and g_conductor is None g_pipeline = pipeline.Pipeline(model.get_doc_model(), options) g_pipeline.initialize() g_conductor = get_conductor(g_pipeline) # Now process the args specified. for i, arg in enumerate(args): try: