622 and backup_name in self.helper.list_databases(self.cursor)) |
622 and backup_name in self.helper.list_databases(self.cursor)) |
623 |
623 |
624 def init_test_database(self): |
624 def init_test_database(self): |
625 """initialize a fresh postgresql database used for testing purpose""" |
625 """initialize a fresh postgresql database used for testing purpose""" |
626 from cubicweb.server import init_repository |
626 from cubicweb.server import init_repository |
627 from cubicweb.server.serverctl import system_source_cnx, createdb |
627 from cubicweb.server.serverctl import source_cnx, createdb |
628 # connect on the dbms system base to create our base |
628 # connect on the dbms system base to create our base |
629 try: |
629 try: |
630 self._drop(self.system_source['db-name']) |
630 self._drop(self.system_source['db-name']) |
631 createdb(self.helper, self.system_source, self.dbcnx, self.cursor) |
631 createdb(self.helper, self.system_source, self.dbcnx, self.cursor) |
632 self.dbcnx.commit() |
632 self.dbcnx.commit() |
633 cnx = system_source_cnx(self.system_source, special_privs='LANGUAGE C', |
633 cnx = source_cnx(self.system_source, special_privs='LANGUAGE C', |
634 interactive=False) |
634 interactive=False) |
635 templcursor = cnx.cursor() |
635 templcursor = cnx.cursor() |
636 try: |
636 try: |
637 # XXX factorize with db-create code |
637 # XXX factorize with db-create code |
638 self.helper.init_fti_extensions(templcursor) |
638 self.helper.init_fti_extensions(templcursor) |
639 # install plpythonu/plpgsql language if not installed by the cube |
639 # install plpythonu/plpgsql language if not installed by the cube |