def testMigrateOldDbFails(self): oldDb = Path(self.testHomeDir) / '.yokadi.db' newDb = Path(basepaths.getDbPath(basepaths.getDataDir())) oldDb.touch() newDb.parent.mkdir(parents=True) newDb.touch() self.assertRaises(basepaths.MigrationException, basepaths.migrateOldDb, str(newDb))
def testMigrateOldDb(self): oldDb = Path(self.testHomeDir) / '.yokadi.db' newDb = Path(basepaths.getDbPath(basepaths.getDataDir())) oldDb.touch() basepaths.migrateOldDb(str(newDb)) self.assertFalse(oldDb.exists()) self.assertTrue(newDb.exists())
def processDataDirArg(dataDir): if dataDir: dataDir = os.path.abspath(dataDir) if not os.path.isdir(dataDir): tui.error("Directory '{}' does not exist".format(dataDir)) sys.exit(1) else: dataDir = basepaths.getDataDir() os.makedirs(dataDir, exist_ok=True) return dataDir
def addArgs(parser): group = parser.add_mutually_exclusive_group() group.add_argument('--datadir', dest='dataDir', help='Database dir (default: %s)' % basepaths.getDataDir(), metavar='DATADIR') group.add_argument( '-d', '--db', dest='dbPath', help= 'TODO database (default: {}). This option is deprecated and will be removed in the next' ' version of Yokadi. Use --datadir instead.'.format( os.path.join('$DATADIR', basepaths.DB_NAME)), metavar='FILE') parser.add_argument('-v', '--version', dest='version', action='store_true', help='Display Yokadi current version')
def setUp(self): super().setUp() self.defaultDataDir = basepaths.getDataDir() self.defaultDbPath = basepaths.getDbPath(self.defaultDataDir)
def testDbEnvVar(self): path = "foo" os.environ["YOKADI_DB"] = path self.assertEqual(basepaths.getDbPath(basepaths.getDataDir()), path)
def testMigrateNothingToDo(self): newDb = Path(basepaths.getDbPath(basepaths.getDataDir())) basepaths.migrateOldDb(str(newDb)) basepaths.migrateOldHistory() self.assertFalse(newDb.exists())
def testGetDataDir(self): expected = os.path.join(self.testAppDataDir, "yokadi", "data") self.assertEqual(basepaths.getDataDir(), expected)
def addArgs(parser): group = parser.add_mutually_exclusive_group() group.add_argument('--datadir', dest='dataDir', help='Database dir (default: %s)' % basepaths.getDataDir(), metavar='DATADIR') group.add_argument('-d', '--db', dest='dbPath', help='TODO database (default: {}). This option is deprecated and will be removed in the next' ' version of Yokadi. Use --datadir instead.' .format(os.path.join('$DATADIR', basepaths.DB_NAME)), metavar='FILE') parser.add_argument('-v', '--version', dest='version', action='store_true', help='Display Yokadi current version')