db: Create a function for checking if this is a new database
So the tagdb can attempt to import tracks if none have been added to the sql database yet. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
f82e299736
commit
6b5b2a745e
|
@ -2,6 +2,13 @@
|
|||
import lib
|
||||
import pathlib
|
||||
|
||||
def new_db():
|
||||
from . import sql
|
||||
try:
|
||||
return sql.execute("SELECT COUNT(*) from tracks").fetchone()[0] == 0
|
||||
except:
|
||||
return True
|
||||
|
||||
|
||||
from . import artist
|
||||
from . import album
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
import db
|
||||
import unittest
|
||||
|
||||
class TestDB(unittest.TestCase):
|
||||
def test_new_db(self):
|
||||
self.assertTrue(db.new_db())
|
||||
db.make_fake_track(1, 1, "Test Track", "/a/b/c/1.ogg")
|
||||
self.assertFalse(db.new_db())
|
Loading…
Reference in New Issue