All tests pass
This commit is contained in:
parent
324dd770df
commit
7f3e235e9d
@ -37,40 +37,40 @@ class MyTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|
||||||
def create_playlist_and_model(
|
def playlist_create_and_model(
|
||||||
self, playlist_name: str
|
self, playlist_name: str
|
||||||
) -> (PlaylistDTO, PlaylistModel):
|
) -> (PlaylistDTO, PlaylistModel):
|
||||||
# Create a playlist and model
|
# Create a playlist and model
|
||||||
playlist = ds.create_playlist(name=playlist_name, template_id=0)
|
playlist = ds.playlist_create(name=playlist_name, template_id=0)
|
||||||
assert playlist
|
assert playlist
|
||||||
model = playlistmodel.PlaylistModel(playlist.playlist_id, is_template=False)
|
model = playlistmodel.PlaylistModel(playlist.playlist_id, is_template=False)
|
||||||
assert model
|
assert model
|
||||||
|
|
||||||
return (playlist, model)
|
return (playlist, model)
|
||||||
|
|
||||||
def create_playlist_model_tracks(self, playlist_name: str):
|
def playlist_create_model_tracks(self, playlist_name: str):
|
||||||
(playlist, model) = self.create_playlist_and_model(playlist_name)
|
(playlist, model) = self.playlist_create_and_model(playlist_name)
|
||||||
# Create tracks
|
# Create tracks
|
||||||
metadata1 = get_all_track_metadata(self.isa_path)
|
metadata1 = get_all_track_metadata(self.isa_path)
|
||||||
self.track1 = ds.create_track(self.isa_path, metadata1)
|
self.track1 = ds.track_create(metadata1)
|
||||||
|
|
||||||
metadata2 = get_all_track_metadata(self.mom_path)
|
metadata2 = get_all_track_metadata(self.mom_path)
|
||||||
self.track2 = ds.create_track(self.mom_path, metadata2)
|
self.track2 = ds.track_create(metadata2)
|
||||||
|
|
||||||
# Add tracks and header to playlist
|
# Add tracks and header to playlist
|
||||||
self.row0 = ds.insert_row(
|
self.row0 = ds.playlist_insert_row(
|
||||||
playlist.playlist_id,
|
playlist.playlist_id,
|
||||||
row_number=0,
|
row_number=0,
|
||||||
track_id=self.track1.track_id,
|
track_id=self.track1.track_id,
|
||||||
note="track 1",
|
note="track 1",
|
||||||
)
|
)
|
||||||
self.row1 = ds.insert_row(
|
self.row1 = ds.playlist_insert_row(
|
||||||
playlist.playlist_id,
|
playlist.playlist_id,
|
||||||
row_number=1,
|
row_number=1,
|
||||||
track_id=0,
|
track_id=0,
|
||||||
note="Header row",
|
note="Header row",
|
||||||
)
|
)
|
||||||
self.row2 = ds.insert_row(
|
self.row2 = ds.playlist_insert_row(
|
||||||
playlist.playlist_id,
|
playlist.playlist_id,
|
||||||
row_number=2,
|
row_number=2,
|
||||||
track_id=self.track2.track_id,
|
track_id=self.track2.track_id,
|
||||||
@ -80,9 +80,9 @@ class MyTestCase(unittest.TestCase):
|
|||||||
def create_rows(
|
def create_rows(
|
||||||
self, playlist_name: str, number_of_rows: int
|
self, playlist_name: str, number_of_rows: int
|
||||||
) -> (PlaylistDTO, PlaylistModel):
|
) -> (PlaylistDTO, PlaylistModel):
|
||||||
(playlist, model) = self.create_playlist_and_model(playlist_name)
|
(playlist, model) = self.playlist_create_and_model(playlist_name)
|
||||||
for row_number in range(number_of_rows):
|
for row_number in range(number_of_rows):
|
||||||
ds.insert_row(
|
ds.playlist_insert_row(
|
||||||
playlist.playlist_id, row_number, None, str(row_number)
|
playlist.playlist_id, row_number, None, str(row_number)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,29 +96,29 @@ class MyTestCase(unittest.TestCase):
|
|||||||
def test_add_track_to_header(self):
|
def test_add_track_to_header(self):
|
||||||
"""Add a track to a header row"""
|
"""Add a track to a header row"""
|
||||||
|
|
||||||
self.create_playlist_model_tracks("my playlist")
|
self.playlist_create_model_tracks("my playlist")
|
||||||
ds.add_track_to_header(self.row1.playlistrow_id, self.track2.track_id)
|
ds.track_add_to_header(self.row1.playlistrow_id, self.track2.track_id)
|
||||||
result = ds.get_playlist_row(self.row1.playlistrow_id)
|
result = ds.playlistrow_by_id(self.row1.playlistrow_id)
|
||||||
assert result.track.track_id == self.track2.track_id
|
assert result.track.track_id == self.track2.track_id
|
||||||
|
|
||||||
def test_create_track(self):
|
def test_track_create(self):
|
||||||
metadata = get_all_track_metadata(self.isa_path)
|
metadata = get_all_track_metadata(self.isa_path)
|
||||||
ds.create_track(self.isa_path, metadata)
|
ds.track_create(metadata)
|
||||||
results = ds.get_all_tracks()
|
results = ds.tracks_all()
|
||||||
assert len(results) == 1
|
assert len(results) == 1
|
||||||
assert results[0].path == self.isa_path
|
assert results[0].path == self.isa_path
|
||||||
|
|
||||||
def test_get_track_by_id(self):
|
def test_get_track_by_id(self):
|
||||||
metadata = get_all_track_metadata(self.isa_path)
|
metadata = get_all_track_metadata(self.isa_path)
|
||||||
dto = ds.create_track(self.isa_path, metadata)
|
dto = ds.track_create(metadata)
|
||||||
result = ds.track_by_id(dto.track_id)
|
result = ds.track_by_id(dto.track_id)
|
||||||
assert result.path == self.isa_path
|
assert result.path == self.isa_path
|
||||||
|
|
||||||
def test_get_track_by_artist(self):
|
def test_get_track_by_artist(self):
|
||||||
metadata = get_all_track_metadata(self.isa_path)
|
metadata = get_all_track_metadata(self.isa_path)
|
||||||
_ = ds.create_track(self.isa_path, metadata)
|
_ = ds.track_create(metadata)
|
||||||
metadata = get_all_track_metadata(self.mom_path)
|
metadata = get_all_track_metadata(self.mom_path)
|
||||||
_ = ds.create_track(self.mom_path, metadata)
|
_ = ds.track_create(metadata)
|
||||||
result_isa = ds.tracks_by_artist(self.isa_artist)
|
result_isa = ds.tracks_by_artist(self.isa_artist)
|
||||||
assert len(result_isa) == 1
|
assert len(result_isa) == 1
|
||||||
assert result_isa[0].artist == self.isa_artist
|
assert result_isa[0].artist == self.isa_artist
|
||||||
@ -128,9 +128,9 @@ class MyTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_track_by_title(self):
|
def test_get_track_by_title(self):
|
||||||
metadata_isa = get_all_track_metadata(self.isa_path)
|
metadata_isa = get_all_track_metadata(self.isa_path)
|
||||||
_ = ds.create_track(self.isa_path, metadata_isa)
|
_ = ds.track_create(metadata_isa)
|
||||||
metadata_mom = get_all_track_metadata(self.mom_path)
|
metadata_mom = get_all_track_metadata(self.mom_path)
|
||||||
_ = ds.create_track(self.mom_path, metadata_mom)
|
_ = ds.track_create(metadata_mom)
|
||||||
result_isa = ds.tracks_by_title(self.isa_title)
|
result_isa = ds.tracks_by_title(self.isa_title)
|
||||||
assert len(result_isa) == 1
|
assert len(result_isa) == 1
|
||||||
assert result_isa[0].title == self.isa_title
|
assert result_isa[0].title == self.isa_title
|
||||||
@ -139,15 +139,15 @@ class MyTestCase(unittest.TestCase):
|
|||||||
assert result_mom[0].title == self.mom_title
|
assert result_mom[0].title == self.mom_title
|
||||||
|
|
||||||
def test_tracks_get_all_tracks(self):
|
def test_tracks_get_all_tracks(self):
|
||||||
self.create_playlist_model_tracks(playlist_name="test_track_get_all_tracks")
|
self.playlist_create_model_tracks(playlist_name="test_track_get_all_tracks")
|
||||||
all_tracks = ds.get_all_tracks()
|
all_tracks = ds.tracks_all()
|
||||||
assert len(all_tracks) == 2
|
assert len(all_tracks) == 2
|
||||||
|
|
||||||
def test_tracks_by_path(self):
|
def test_tracks_by_path(self):
|
||||||
metadata_isa = get_all_track_metadata(self.isa_path)
|
metadata_isa = get_all_track_metadata(self.isa_path)
|
||||||
_ = ds.create_track(self.isa_path, metadata_isa)
|
_ = ds.track_create(metadata_isa)
|
||||||
metadata_mom = get_all_track_metadata(self.mom_path)
|
metadata_mom = get_all_track_metadata(self.mom_path)
|
||||||
_ = ds.create_track(self.mom_path, metadata_mom)
|
_ = ds.track_create(metadata_mom)
|
||||||
result_isa = ds.track_by_path(self.isa_path)
|
result_isa = ds.track_by_path(self.isa_path)
|
||||||
assert result_isa.title == self.isa_title
|
assert result_isa.title == self.isa_title
|
||||||
result_mom = ds.track_by_path(self.mom_path)
|
result_mom = ds.track_by_path(self.mom_path)
|
||||||
@ -159,7 +159,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 10
|
number_of_rows = 10
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test1", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test1", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([3], playlist.playlist_id, 5)
|
ds.playlist_move_rows([3], playlist.playlist_id, 5)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -173,7 +173,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 10
|
number_of_rows = 10
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test2", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test2", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([4], playlist.playlist_id, 3)
|
ds.playlist_move_rows([4], playlist.playlist_id, 3)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -187,7 +187,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 10
|
number_of_rows = 10
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test3", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test3", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([4], playlist.playlist_id, 2)
|
ds.playlist_move_rows([4], playlist.playlist_id, 2)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -201,7 +201,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 11
|
number_of_rows = 11
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test4", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test4", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([1, 4, 5, 10], playlist.playlist_id, 8)
|
ds.playlist_move_rows([1, 4, 5, 10], playlist.playlist_id, 8)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -215,7 +215,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 11
|
number_of_rows = 11
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test5", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test5", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([3, 6], playlist.playlist_id, 5)
|
ds.playlist_move_rows([3, 6], playlist.playlist_id, 5)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -229,7 +229,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 11
|
number_of_rows = 11
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test6", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test6", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([3, 5, 6], playlist.playlist_id, 8)
|
ds.playlist_move_rows([3, 5, 6], playlist.playlist_id, 8)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -243,7 +243,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 11
|
number_of_rows = 11
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test7", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test7", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([7, 8, 10], playlist.playlist_id, 5)
|
ds.playlist_move_rows([7, 8, 10], playlist.playlist_id, 5)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -258,7 +258,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
number_of_rows = 11
|
number_of_rows = 11
|
||||||
(playlist, model) = self.create_rows("test_move_rows_test8", number_of_rows)
|
(playlist, model) = self.create_rows("test_move_rows_test8", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows([0, 1, 2, 3], playlist.playlist_id, 0)
|
ds.playlist_move_rows([0, 1, 2, 3], playlist.playlist_id, 0)
|
||||||
|
|
||||||
# Check we have all rows and plr_rownums are correct
|
# Check we have all rows and plr_rownums are correct
|
||||||
new_order = []
|
new_order = []
|
||||||
@ -274,7 +274,7 @@ class MyTestCase(unittest.TestCase):
|
|||||||
(playlist_src, model_src) = self.create_rows("src playlist", number_of_rows)
|
(playlist_src, model_src) = self.create_rows("src playlist", number_of_rows)
|
||||||
(playlist_dst, model_dst) = self.create_rows("dst playlist", number_of_rows)
|
(playlist_dst, model_dst) = self.create_rows("dst playlist", number_of_rows)
|
||||||
|
|
||||||
ds.move_rows(
|
ds.playlist_move_rows(
|
||||||
rows_to_move, playlist_src.playlist_id, to_row, playlist_dst.playlist_id
|
rows_to_move, playlist_src.playlist_id, to_row, playlist_dst.playlist_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user