Пример #1
0
    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))
Пример #2
0
    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())
Пример #3
0
    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())
Пример #4
0
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
Пример #5
0
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
Пример #6
0
    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))
Пример #7
0
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')
Пример #8
0
 def setUp(self):
     super().setUp()
     self.defaultDataDir = basepaths.getDataDir()
     self.defaultDbPath = basepaths.getDbPath(self.defaultDataDir)
Пример #9
0
 def testDbEnvVar(self):
     path = "foo"
     os.environ["YOKADI_DB"] = path
     self.assertEqual(basepaths.getDbPath(basepaths.getDataDir()), path)
Пример #10
0
 def testMigrateNothingToDo(self):
     newDb = Path(basepaths.getDbPath(basepaths.getDataDir()))
     basepaths.migrateOldDb(str(newDb))
     basepaths.migrateOldHistory()
     self.assertFalse(newDb.exists())
Пример #11
0
 def testGetDataDir(self):
     expected = os.path.join(self.testAppDataDir, "yokadi", "data")
     self.assertEqual(basepaths.getDataDir(), expected)
Пример #12
0
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')
Пример #13
0
 def testGetDataDir(self):
     expected = os.path.join(self.testAppDataDir, "yokadi", "data")
     self.assertEqual(basepaths.getDataDir(), expected)
Пример #14
0
 def testDbEnvVar(self):
     path = "foo"
     os.environ["YOKADI_DB"] = path
     self.assertEqual(basepaths.getDbPath(basepaths.getDataDir()), path)
Пример #15
0
 def testMigrateNothingToDo(self):
     newDb = Path(basepaths.getDbPath(basepaths.getDataDir()))
     basepaths.migrateOldDb(str(newDb))
     basepaths.migrateOldHistory()
     self.assertFalse(newDb.exists())
Пример #16
0
 def setUp(self):
     super().setUp()
     self.defaultDataDir = basepaths.getDataDir()
     self.defaultDbPath = basepaths.getDbPath(self.defaultDataDir)