def delete_all_export_data_schemas(): from .models import ExportDataSchema db = ExportDataSchema.get_db() for row in db.view('schemas_by_xmlns_or_case_type/view', reduce=False): doc_id = row['id'] safe_delete(db, doc_id)
def delete_all_export_instances(): from .models import ExportInstance db = ExportInstance.get_db() for row in db.view('export_instances_by_domain/view', reduce=False): doc_id = row['id'] safe_delete(db, doc_id)
def delete_all_inferred_schemas(): from .models import InferredSchema db = InferredSchema.get_db() for row in db.view('inferred_schemas_by_case_type/view', reduce=False): doc_id = row['id'] safe_delete(db, doc_id)
def _delete_all(db, viewname): deleted = set() for row in db.view(viewname, reduce=False): doc_id = row['id'] if id not in deleted: try: safe_delete(db, doc_id) deleted.add(doc_id) except ResourceNotFound: pass
def _delete_all_from_view(db, view, view_kwargs=None): view_kwargs = view_kwargs or {} deleted = set() for row in db.view(view, reduce=False, **view_kwargs): doc_id = row['id'] if doc_id not in deleted: try: safe_delete(db, doc_id) deleted.add(doc_id) except ResourceNotFound: pass
def setUp(self): # We want to support Python 2.6 a bit longer so we cannot use dictConfig here... # but it is so handy that we put it in settings.py instead of wrestle with crappy # imperative config self.logger = logging.getLogger('couchlog.tests') self.original_log_level = logging.root.getEffectiveLevel() for handler in list(self.logger.handlers): if isinstance(handler, CouchHandler): self.logger.removeHandler(handler) logging.root.setLevel(logging.ERROR) init_handler() self.db = ExceptionRecord.get_db() for row in self.db.view("couchlog/all_by_date").all(): safe_delete(self.db, row['id'])
def setUp(self): db = ExceptionRecord.get_db() for row in db.view("couchlog/all_by_date").all(): safe_delete(db, row['id'])
def _delete_all(db, viewname, id_func=None): for row in db.view(viewname, reduce=False): try: safe_delete(db, id_func(row) if id_func else row['id']) except ResourceNotFound: pass
def tearDown(self): db = ExportDataSchema.get_db() for row in db.view('schemas_by_xmlns_or_case_type/view', reduce=False): doc_id = row['id'] safe_delete(db, doc_id)