forked from openlp/openlp
attempt to fix some tests in windows
This commit is contained in:
parent
fb8ee9a546
commit
9e8fe903a7
@ -40,11 +40,18 @@ class TestUtilsDBFunctions(TestCase):
|
|||||||
Create temp folder for keeping db file
|
Create temp folder for keeping db file
|
||||||
"""
|
"""
|
||||||
self.tmp_folder = mkdtemp()
|
self.tmp_folder = mkdtemp()
|
||||||
|
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||||
|
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
||||||
|
shutil.copyfile(db_path, db_tmp_path)
|
||||||
|
db_url = 'sqlite:///' + db_tmp_path
|
||||||
|
self.session, metadata = init_db(db_url)
|
||||||
|
self.op = get_upgrade_op(self.session)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
Clean up
|
Clean up
|
||||||
"""
|
"""
|
||||||
|
self.session.close()
|
||||||
shutil.rmtree(self.tmp_folder)
|
shutil.rmtree(self.tmp_folder)
|
||||||
|
|
||||||
def delete_column_test(self):
|
def delete_column_test(self):
|
||||||
@ -52,18 +59,12 @@ class TestUtilsDBFunctions(TestCase):
|
|||||||
Test deleting a single column in a table
|
Test deleting a single column in a table
|
||||||
"""
|
"""
|
||||||
# GIVEN: A temporary song db
|
# GIVEN: A temporary song db
|
||||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
|
||||||
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
|
||||||
shutil.copyfile(db_path, db_tmp_path)
|
|
||||||
db_url = 'sqlite:///' + db_tmp_path
|
|
||||||
session, metadata = init_db(db_url)
|
|
||||||
op = get_upgrade_op(session)
|
|
||||||
|
|
||||||
# WHEN: Deleting a columns in a table
|
# WHEN: Deleting a columns in a table
|
||||||
drop_column(op, 'songs', 'song_book_id')
|
drop_column(self.op, 'songs', 'song_book_id')
|
||||||
|
|
||||||
# THEN: The column should have been deleted
|
# THEN: The column should have been deleted
|
||||||
meta = sqlalchemy.MetaData(bind=op.get_bind())
|
meta = sqlalchemy.MetaData(bind=self.op.get_bind())
|
||||||
meta.reflect()
|
meta.reflect()
|
||||||
columns = meta.tables['songs'].columns
|
columns = meta.tables['songs'].columns
|
||||||
|
|
||||||
@ -76,21 +77,16 @@ class TestUtilsDBFunctions(TestCase):
|
|||||||
Test deleting multiple columns in a table
|
Test deleting multiple columns in a table
|
||||||
"""
|
"""
|
||||||
# GIVEN: A temporary song db
|
# GIVEN: A temporary song db
|
||||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
|
||||||
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
|
||||||
shutil.copyfile(db_path, db_tmp_path)
|
|
||||||
db_url = 'sqlite:///' + db_tmp_path
|
|
||||||
session, metadata = init_db(db_url)
|
|
||||||
op = get_upgrade_op(session)
|
|
||||||
|
|
||||||
# WHEN: Deleting a columns in a table
|
# WHEN: Deleting a columns in a table
|
||||||
drop_columns(op, 'songs', ['song_book_id', 'song_number'])
|
drop_columns(self.op, 'songs', ['song_book_id', 'song_number'])
|
||||||
|
|
||||||
# THEN: The columns should have been deleted
|
# THEN: The columns should have been deleted
|
||||||
meta = sqlalchemy.MetaData(bind=op.get_bind())
|
meta = sqlalchemy.MetaData(bind=self.op.get_bind())
|
||||||
meta.reflect()
|
meta.reflect()
|
||||||
columns = meta.tables['songs'].columns
|
columns = meta.tables['songs'].columns
|
||||||
|
|
||||||
for column in columns:
|
for column in columns:
|
||||||
if column.name == 'song_book_id' or column.name == 'song_number':
|
if column.name == 'song_book_id' or column.name == 'song_number':
|
||||||
self.fail("The column '%s' should have been deleted." % column.name)
|
self.fail("The column '%s' should have been deleted." % column.name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user