Esempio n. 1
0
 def write(self) -> None:
     """Write the example DB to a SQLite DB and change the DB path."""
     self.tmp_dbdir = tempfile.mkdtemp()
     self.old_path = getconfig("database.path")
     setconfig("database.path", self.tmp_dbdir)
     dbman = CLIDbManager(DbState())
     dbman.import_new_db(self.path, User())
Esempio n. 2
0
 def test_example_db_sqlite(self):
     """Test the SQLite example DB."""
     db = ExampleDbSQLite()
     db.write()
     self.assertEqual(getconfig("database.path"), db.tmp_dbdir)
     dbman = CLIDbManager(DbState())
     db_info = dbman.current_names
     # there is only one DB here
     self.assertEqual(len(db_info), 1)
     # DB name
     self.assertEqual(db_info[0][0], "example")
     # DB path
     self.assertEqual(os.path.dirname(db_info[0][1]), db.tmp_dbdir)
     db.delete()
     # just check that this is not at the tmp dir anymore
     self.assertNotEqual(getconfig("database.path"), db.tmp_dbdir)
     # ... and that the tmp dir is gone
     self.assertTrue(not os.path.exists(db.tmp_dbdir))
Esempio n. 3
0
 def setUp(self):
     from gramps.cli.clidbman import CLIDbManager
     from gramps.gen.config import set as setconfig, get as getconfig
     from gramps.gen.dbstate import DbState
     self.newpath = os.path.join(os.path.dirname(__file__),
                                 '\u0393\u03c1\u03b1\u03bc\u03c3\u03c0')
     self.newtitle = 'Gr\u00e4mps T\u00e9st'
     os.makedirs(self.newpath)
     self.old_path = getconfig('database.path')
     setconfig('database.path', self.newpath)
     self.cli = CLIDbManager(DbState())
Esempio n. 4
0
 def setUp(self):
     from gramps.cli.clidbman import CLIDbManager
     from gramps.gen.config import set as setconfig, get as getconfig
     from gramps.gen.dbstate import DbState
     self.newpath = os.path.join(os.path.dirname(__file__),
                                 '\u0393\u03c1\u03b1\u03bc\u03c3\u03c0')
     self.newtitle = 'Gr\u00e4mps T\u00e9st'
     os.makedirs(self.newpath)
     self.old_path = getconfig('behavior.database-path')
     setconfig('behavior.database-path', self.newpath)
     self.cli = CLIDbManager(DbState())
Esempio n. 5
0
 def test_example_db_sqlite(self):
     """Test the SQLite example DB."""
     test_grampshome = tempfile.mkdtemp()
     os.environ["GRAMPSHOME"] = test_grampshome
     db = ExampleDbSQLite()
     self.assertEqual(getconfig("database.path"), db.db_path)
     dbman = CLIDbManager(DbState())
     db_info = dbman.current_names
     # there is only one DB here
     self.assertEqual(len(db_info), 1)
     # DB name
     self.assertEqual(db_info[0][0], "example")
     # DB path
     self.assertEqual(os.path.dirname(db_info[0][1]), db.db_path)
     # DB cleanup
     shutil.rmtree(test_grampshome)
     self.assertTrue(not os.path.exists(test_grampshome))