@@ -1463,7 +1463,8 @@ def test_load_videos():
1463
1463
assert Video .objects .count () == len (video_resources )
1464
1464
1465
1465
1466
- def test_load_playlist (mocker ):
1466
+ @pytest .mark .parametrize ("playlist_exists" , [True , False ])
1467
+ def test_load_playlist (mocker , playlist_exists ):
1467
1468
"""Test load_playlist"""
1468
1469
expected_topics = [{"name" : "Biology" }, {"name" : "Physics" }]
1469
1470
[
@@ -1475,9 +1476,19 @@ def test_load_playlist(mocker):
1475
1476
return_value = expected_topics ,
1476
1477
)
1477
1478
channel = VideoChannelFactory .create ()
1478
- playlist = VideoPlaylistFactory .build ().learning_resource
1479
- assert VideoPlaylist .objects .count () == 0
1480
- assert Video .objects .count () == 0
1479
+ if playlist_exists :
1480
+ playlist = VideoPlaylistFactory .create (channel = channel ).learning_resource
1481
+ deleted_video = VideoFactory .create ().learning_resource
1482
+ playlist .resources .add (
1483
+ deleted_video ,
1484
+ through_defaults = {
1485
+ "relation_type" : LearningResourceRelationTypes .PLAYLIST_VIDEOS ,
1486
+ "position" : 1 ,
1487
+ },
1488
+ )
1489
+ else :
1490
+ playlist = VideoPlaylistFactory .build ().learning_resource
1491
+
1481
1492
video_resources = [video .learning_resource for video in VideoFactory .build_batch (5 )]
1482
1493
videos_data = [
1483
1494
{
@@ -1511,6 +1522,9 @@ def test_load_playlist(mocker):
1511
1522
assert list (result .topics .values_list ("name" , flat = True ).order_by ("name" )) == [
1512
1523
topic ["name" ] for topic in expected_topics
1513
1524
]
1525
+ if playlist_exists :
1526
+ deleted_video .refresh_from_db ()
1527
+ assert not deleted_video .published
1514
1528
1515
1529
1516
1530
def test_load_playlists_unpublish (mocker ):
0 commit comments